Locale bundled files are now cleaned up on exit.
authorshort <>
Sun, 26 Jun 2005 06:20:43 +0000 (06:20 +0000)
committershort <>
Sun, 26 Jun 2005 06:20:43 +0000 (06:20 +0000)
Locale bundled files are stored accessibly if no permissions for: LOCALEDIR

src/main.c

index e9833d9..c2cec2c 100644 (file)
@@ -134,6 +134,8 @@ static void gnome_init_g_log_handler(const gchar *log_domain,GLogLevelFlags log_
 }
 #endif /* HAVE_GNOME */
 
+static const gchar *localedir;
+
 #ifdef ENABLE_BUNDLE
 static gboolean locale_files_write(void)
 {
@@ -148,13 +150,27 @@ gchar *cc,*cc_end;
                        *catalog_next++='\0';
                cc=g_strdup(catalog);
                cc_end=cc+strlen(cc)-strlen(".gmo");
-               if (!strcmp(cc_end,".gmo")) {   /* errors ignored */
+               if (cc_end>cc && !strcmp(cc_end,".gmo")) {
                        *cc_end='\0';
-                       bundle_util_file_write( /* errors ignored */
+                       if (!bundle_util_file_write(
                                        udpgate_printf_alloca("%s/%s/LC_MESSAGES/%s.mo",LOCALEDIR,cc,PACKAGE),  /* pathname */
                                        catalog,        /* basename */
                                        0644,   /* pathname_mode */
-                                       FALSE); /* pathname_backup */
+                                       BUNDLE_UTIL_MKDIRS_MASK|BUNDLE_UTIL_TEMPORARY_MASK)) {  /* flags */
+const gchar *tmpdir=g_get_tmp_dir();
+const gchar *username=g_get_user_name();
+gchar *trylocaledir=localedir;
+
+                               if (!trylocaledir && tmpdir && username)
+                                       trylocaledir=g_strdup_printf("%s/.%s-%s/locale",tmpdir,username,PACKAGE);
+                               if (trylocaledir && bundle_util_file_write(
+                                               udpgate_printf_alloca("%s/%s/LC_MESSAGES/%s.mo",trylocaledir,cc,PACKAGE),       /* pathname */
+                                               catalog,        /* basename */
+                                               0644,   /* pathname_mode */
+                                               BUNDLE_UTIL_MKDIRS_MASK|BUNDLE_UTIL_TEMPORARY_MASK))    /* flags */
+                                       localedir=trylocaledir;
+                               }
+
                        }
                g_free(cc);
                }
@@ -186,7 +202,9 @@ int exit_rc=EXIT_SUCCESS;
 
        /* Initialize the i18n stuff */
        setlocale(LC_ALL,"");
-       bindtextdomain(PACKAGE,LOCALEDIR);
+       if (!localedir)
+               localedir=LOCALEDIR;
+       bindtextdomain(PACKAGE,localedir);
        textdomain(PACKAGE);
 
        /* Read it before the command-line parsing to get the default value