[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

filename output patch



This is one patch from series patches resolves
i18n problems in dia (with translations and encoding).

Changelog:
  implement dia_message_filename function for translate filename
from filename encoding to UTF8.

Use it in such code as
message_warning(_("Too many ..'s in filename %s\n"),
                    dia_message_filename(filename));

You can see an example in the patch.

P.S.
There is too many code with all changes (about 60Kb), I will try 
send it by small pieces in this list. Is it right place?

-- 
Lav
Vitaly Lipatov
Russia, Saint-Petersburg
GNU! ALT Linux Team! LaTeX! LyX!
Index: lib/dia_dirs.c
===================================================================
RCS file: /cvs/gnome/dia/lib/dia_dirs.c,v
retrieving revision 1.20
diff -u -r1.20 dia_dirs.c
--- lib/dia_dirs.c	15 Jan 2005 16:46:09 -0000	1.20
+++ lib/dia_dirs.c	6 Mar 2005 11:51:09 -0000
@@ -21,6 +21,7 @@
 #include <string.h> /* strlen() */
 
 #include "dia_dirs.h"
+#include "intl.h"
 #include "message.h"
 #ifdef G_OS_WIN32
 #include <windows.h>
@@ -188,6 +189,35 @@
   return ret;
 }
 
+/** Return an filename in UTF-8 encoding from filename in filesystem
+ * encoding. 
+ * The value returned is a pointer to static array.
+ * Note: The string can be used AFTER the next call to this function
+ *       Written like glib/gstrfuncs.c#g_strerror()
+ */
+
+const gchar *
+dia_message_filename (const gchar *filename)
+{
+  gchar *tmp;
+#if GLIB_CHECK_VERSION(2,6,0)
+  tmp = g_filename_display_name(filename);
+#else
+  tmp = g_filename_to_utf8(filename, -1, NULL, NULL, NULL);
+  if (tmp == NULL) {
+    message_warning(_("Some characters in the filename are neither UTF-8\n" 
+		    "nor your local encoding.\nSome things will break."));
+    tmp = g_strdup(filename);
+  }
+#endif
+  /* Stick in the quark table so that we can return a static result
+   */
+  GQuark msg_quark = g_quark_from_string (tmp);
+  g_free (tmp);
+  tmp = (gchar *) g_quark_to_string (msg_quark);
+  return tmp;
+}
+
 /** Return an absolute filename from an absolute or relative filename.
  * The value returned is newly allocated. 
  */
@@ -205,9 +235,11 @@
   if (strchr(fullname, '.') == NULL) return fullname;
   canonical = dia_get_canonical_path(fullname);
   if (canonical == NULL) {
-    message_warning("Too many ..'s in filename %s\n", filename);
+    message_warning(_("Too many ..'s in filename %s\n"),
+                    dia_message_filename(filename));
     return g_strdup(filename);
   }
   g_free(fullname);
   return canonical;
 }
+

Index: lib/dia_dirs.h
===================================================================
RCS file: /cvs/gnome/dia/lib/dia_dirs.h,v
retrieving revision 1.4
diff -u -r1.4 dia_dirs.h
--- lib/dia_dirs.h	30 Dec 2003 14:31:43 -0000	1.4
+++ lib/dia_dirs.h	6 Mar 2005 11:51:09 -0000
@@ -32,4 +32,6 @@
 gchar *dia_config_filename    (const gchar* file);
 gboolean dia_config_ensure_dir  (const gchar* filename);
 gchar *dia_get_absolute_filename (const gchar *filename);
+const gchar *dia_message_filename (const gchar *filename);
+
 #endif /* DIA_DIRS_H */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index] Mail converted by Mofo Magic and the Flying D

 
All trademarks and copyrights are the property of their respective owners.

Other Directory Sites: SeekWonder | Directory Owners Forum

GuideSMACK