Update locale and add --locale-append argument of ibus-x11
authorPeng Huang <shawn.p.huang@gmail.com>
Fri, 8 May 2009 05:12:46 +0000 (13:12 +0800)
committerPeng Huang <shawn.p.huang@gmail.com>
Fri, 8 May 2009 05:12:46 +0000 (13:12 +0800)
client/x11/Makefile.am
client/x11/locales.h [new file with mode: 0644]
client/x11/main.c

index bd2efab..7812b00 100644 (file)
@@ -53,6 +53,7 @@ ibus_x11_CFLAGS = \
 
 noinst_HEADERS = \
        gdk-private.h \
+       locales.h \
        $(NULL)
 
 $(IMdkit):
@@ -61,3 +62,10 @@ $(IMdkit):
 $(libibus):
        (cd $(top_builddir)/src; make)
 
+locales.h:
+       ( \
+               locale -a | \
+               gawk -F _ '{ if (length($$1) <= 3) print $$1 }' | \
+               uniq | sort | \
+               xargs python -c 'import sys;print "#define LOCALES_STRING \"%s\"" % ",".join(sys.argv[1:])' \
+        ) > $@
diff --git a/client/x11/locales.h b/client/x11/locales.h
new file mode 100644 (file)
index 0000000..8c75223
--- /dev/null
@@ -0,0 +1 @@
+#define LOCALES_STRING "aa,af,am,an,ar,as,ast,az,be,ber,bg,bn,bo,br,bs,byn,C,ca,crh,cs,csb,cy,da,de,dz,el,en,es,et,eu,fa,fi,fil,fo,fr,fur,fy,ga,gd,gez,gl,gu,gv,ha,he,hi,hne,hr,hsb,ht,hu,hy,id,ig,ik,is,it,iu,iw,ja,ka,kk,kl,km,kn,ko,ks,ku,kw,ky,lg,li,lo,lt,lv,mai,mg,mi,mk,ml,mn,mr,ms,mt,nan,nb,nds,ne,nl,nn,no,nr,nso,oc,om,or,pa,pa,pap,pl,pt,ro,ru,rw,sa,sc,sd,se,shs,si,sid,sk,sl,so,sq,sr,ss,st,sv,ta,te,tg,th,ti,tig,tk,tl,tn,tr,ts,tt,ug,uk,ur,uz,ve,vi,wa,wo,xh,yi,yo,zh,zu"
index 53389a9..b8de5d0 100644 (file)
@@ -46,6 +46,7 @@
 
 #include <ibus.h>
 #include "gdk-private.h"
+#include "locales.h"
 
 struct _X11ICONN {
     GList        *clients;
@@ -102,6 +103,9 @@ static GHashTable     *_x11_ic_table = NULL;
 static GHashTable     *_connections = NULL;
 static XIMS _xims = NULL;
 static gchar _server_name[128] = "ibus";
+#ifdef LOCALES_STRING
+static gchar _locale[1024] = LOCALES_STRING;
+#else
 static gchar _locale[1024] =
     "aa,af,am,an,ar,as,az,be,bg,bn,br,bs,"
     "ca,cs,cy,da,de,dz,el,en,es,et,eu,"
@@ -113,6 +117,7 @@ static gchar _locale[1024] =
     "se,si,sk,sl,so,sq,sr,ss,st,sv,"
     "ta,te,tg,th,ti,tl,tn,tr,ts,tt,"
     "uk,ur,uz,ve,vi,wa,xh,yi,zh,zu";
+#endif
 
 static gboolean _kill_daemon = FALSE;
 static gint     g_debug_level = 0;
@@ -999,7 +1004,8 @@ _print_usage (FILE *fp, gchar *name)
         "Usage:\n"
         " %s --help               Show this message\n"
         "    --server-name= -n    Setup xim sevrer name\n"
-        "    --locale= -l         Setup support locale\n"
+        "    --locale= -l         Setup support locales\n"
+        "    --locale-append= -a  Append locales into the default support locales\n"
         "    --kill-daemon -k     Kill ibus daemon when exit\n"
         "    --debug= -v          Setup debug level\n",
         name);
@@ -1026,15 +1032,16 @@ main (int argc, char **argv)
 
     while (1) {
         static struct option long_options [] = {
-            {"debug", 1, 0, 0},
-            {"server-name", 1, 0, 0},
-            {"locale", 1, 0, 0},
-            {"help", 0, 0, 0},
-            {"kill-daemon", 0, 0, 0},
-            {0, 0, 0, 0},
+            { "debug", 1, 0, 0},
+            { "server-name", 1, 0, 0},
+            { "locale", 1, 0, 0},
+            { "locale-append", 1, 0, 0},
+            { "help", 0, 0, 0},
+            { "kill-daemon", 0, 0, 0},
+            { 0, 0, 0, 0},
         };
 
-        c = getopt_long (argc, argv, "v:n:l:k",
+        c = getopt_long (argc, argv, "v:n:l:k:a",
             long_options, &option_index);
 
         if (c == -1) break;
@@ -1050,6 +1057,9 @@ main (int argc, char **argv)
             else if (g_strcmp0 (long_options[option_index].name, "locale") == 0) {
                 strncpy (_locale, optarg, sizeof (_locale));
             }
+            else if (g_strcmp0 (long_options[option_index].name, "locale-append") == 0) {
+                strncat (_locale, optarg, sizeof (_locale));
+            }
             else if (g_strcmp0 (long_options[option_index].name, "help") == 0) {
                 _print_usage (stdout, argv[0]);
                 exit (EXIT_SUCCESS);
@@ -1067,6 +1077,9 @@ main (int argc, char **argv)
         case 'l':
             strncpy (_locale, optarg, sizeof (_locale));
             break;
+        case 'a':
+            strncat (_locale, optarg, sizeof (_locale));
+            break;
         case 'k':
             _kill_daemon = TRUE;
             break;