+Locale catalogs rewriting if --enable-bundle.
[udpgate.git] / src / main.c
index 4e38270..6e4db2c 100644 (file)
@@ -38,6 +38,9 @@
 #include "network.h"
 #include "configuration.h"
 #include "startup.h"
+#ifdef ENABLE_BUNDLE
+#include "bundle-util.h"
+#endif
 
 #ifdef HAVE_GNOME
 #include "ui-gnome.h"
@@ -131,6 +134,34 @@ static void gnome_init_g_log_handler(const gchar *log_domain,GLogLevelFlags log_
 }
 #endif /* HAVE_GNOME */
 
+#ifdef ENABLE_BUNDLE
+static gboolean locale_files_write(void)
+{
+gchar catalogs[]=G_STRINGIFY(CATALOGS);
+gchar *catalog,*catalog_next;
+
+       for (catalog=catalogs;*catalog;catalog=catalog_next) {
+gchar *cc,*cc_end;
+
+               for (catalog_next=catalog;*catalog_next && *catalog_next!=' ';catalog_next++);
+               if (*catalog_next)
+                       *catalog_next++='\0';
+               cc=g_strdup(catalog);
+               cc_end=cc+strlen(cc)-strlen(".gmo");
+               if (!strcmp(cc_end,".gmo")) {   /* errors ignored */
+                       *cc_end='\0';
+                       bundle_util_file_write( /* errors ignored */
+                                       udpgate_printf_alloca("%s/%s/LC_MESSAGES/%s.mo",LOCALEDIR,cc,PACKAGE),  /* pathname */
+                                       catalog,        /* basename */
+                                       0644,   /* pathname_mode */
+                                       FALSE); /* pathname_backup */
+                       }
+               g_free(cc);
+               }
+       return FALSE;
+}
+#endif /* ENABLE_BUNDLE */
+
 int main(int argc,char **argv)
 {
 poptContext context;
@@ -141,6 +172,10 @@ gboolean no_gnome;
 #endif /* HAVE_GNOME */
 int exit_rc=EXIT_SUCCESS;
 
+#ifdef ENABLE_BUNDLE
+       locale_files_write();
+#endif /* ENABLE_BUNDLE */
+
 #if 0
        g_log_set_always_fatal(~(0
                        |G_LOG_LEVEL_MESSAGE