internationalize engine's name
authorHuang Peng <shawn.p.huang@gmail.com>
Fri, 22 Aug 2008 04:01:56 +0000 (12:01 +0800)
committerHuang Peng <shawn.p.huang@gmail.com>
Fri, 22 Aug 2008 04:01:56 +0000 (12:01 +0800)
daemon/register.py
ibus/interface/iibus.py
po/zh_CN.po
setup/main.py
setup/setup.glade

index 73a6a6d..29fa8c7 100644 (file)
@@ -24,13 +24,18 @@ from os import path
 import signal
 import glob
 import ibus
+import locale
+
+locale.setlocale(locale.LC_ALL, "")
+LANG = locale.getlocale()[0], locale.getlocale()[0].split("_")[0]
 
 IBUS_DATAROOTDIR = os.getenv("IBUS_DATAROOTDIR")
 
 class Engine(ibus.Object):
-    def __init__(self, name, lang = "other", icon = "", author = "", credits = "", _exec = "", pid = 0):
+    def __init__(self, name, local_name, lang = "other", icon = "", author = "", credits = "", _exec = "", pid = 0):
         super(Engine, self).__init__()
         self.name = name
+        self.local_name = local_name
         self.lang = lang
         self.icon = icon
         self.author = author
@@ -74,7 +79,7 @@ class Engine(ibus.Object):
             self._exec == o._exec
 
     def __str__(self):
-        return "Engine('%s', '%s', '%s', '%s', '%s', '%s', %d" % (self.name, self.lang, \
+        return "Engine('%s', '%s', '%s', '%s', '%s', '%s', '%s', %d" % (self.name, self.local_name, self.lang, \
             self.icon, self.author, \
             self.credits, self._exec, \
             self.pid)
@@ -114,7 +119,7 @@ class Register(ibus.Object):
     def list_engines(self):
         engines = []
         for key, e in self.__engines.items():
-            engines.append((e.name, e.lang, e.icon, e.author, e.credits, e._exec, e.pid != 0))
+            engines.append((e.name, e.local_name, e.lang, e.icon, e.author, e.credits, e._exec, e.pid != 0))
         return engines
 
     def reload_engines(self):
@@ -146,6 +151,7 @@ class Register(ibus.Object):
     def __load_engine(self, _file):
         f = file(_file)
         name = None
+        local_name = None
         lang = "other"
         icon = ""
         author = ""
@@ -160,6 +166,11 @@ class Register(ibus.Object):
             n, v = l.split("=")
             if n == "Name":
                 name = v
+                if local_name == None:
+                    local_name = name
+            elif n.startswith("Name."):
+                if n[5:] in LANG:
+                    local_name = v
             elif n == "Lang":
                 lang = v
             elif n == "Icon":
@@ -178,7 +189,7 @@ class Register(ibus.Object):
         if _exec == None:
             raise Exception("%s: no exec" % _file)
 
-        return Engine(name, lang, icon, author, credits, _exec)
+        return Engine(name, local_name, lang, icon, author, credits, _exec)
 
 if __name__ == "__main__":
     import time
index fd43678..8fd3d2f 100644 (file)
@@ -110,7 +110,7 @@ class IIBus(dbus.service.Object):
     @async_method(in_signature = "s", out_signature = "v")
     def ConfigGetValue(self, key, dbusconn, reply_cb, error_cb): pass
 
-    @method(out_signature = "a(ssssssb)")
+    @method(out_signature = "a(sssssssb)")
     def RegisterListEngines(self, dbusconn): pass
 
     @method()
index 2652a91..48c1674 100644 (file)
@@ -7,7 +7,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: 0.1.1.20080813\n"
 "Report-Msgid-Bugs-To: http://code.google.com/p/ibus/issues/entry\n"
-"POT-Creation-Date: 2008-08-22 10:54+0800\n"
+"POT-Creation-Date: 2008-08-22 11:17+0800\n"
 "PO-Revision-Date: 2008-08-13 21:59+0800\n"
 "Last-Translator: Huang Peng <shawn.p.huang@gmail.com>\n"
 "Language-Team: Huang Peng <shawn.p.huang@gmail.com>\n"
@@ -420,15 +420,15 @@ msgstr "预加载"
 msgid "Select keyboard shortcut for %s"
 msgstr "选择%s的快捷键"
 
-#: setup/keyboardshortcut.py:60
+#: setup/keyboardshortcut.py:62
 msgid "Key code:"
 msgstr "按键:"
 
-#: setup/keyboardshortcut.py:75
+#: setup/keyboardshortcut.py:77
 msgid "Modifiers:"
 msgstr "修饰符:"
 
-#: setup/keyboardshortcut.py:204
+#: setup/keyboardshortcut.py:206
 msgid ""
 "Please press a key (or a key combination).\n"
 "The dialog will be closed when the key is released."
@@ -436,7 +436,7 @@ msgstr ""
 "请按一个键盘按键(或者一个组合按键)\n"
 "当您松开任意按键时,对话框会自动关闭。"
 
-#: setup/keyboardshortcut.py:206
+#: setup/keyboardshortcut.py:208
 msgid "Please press a key (or a key combination)"
 msgstr "请按一个键盘按键(或者一个组合按键)"
 
index e9cf7c4..b4eeb74 100644 (file)
@@ -45,6 +45,7 @@ N_ = lambda a : a
 
 (
     DATA_NAME,
+    DATA_LOCAL_NAME,
     DATA_LANG,
     DATA_ICON,
     DATA_AUTHOR,
@@ -52,7 +53,7 @@ N_ = lambda a : a
     DATA_EXEC,
     DATA_STARTED,
     DATA_PRELOAD
-) = range(8)
+) = range(9)
 
 CONFIG_GENERAL_SHORTCUT = "/general/keyboard_shortcut_%s"
 CONFIG_PRELOAD_ENGINES = "/general/preload_engines"
@@ -225,6 +226,8 @@ class Setup(object):
                         buttons = gtk.BUTTONS_CLOSE,
                         message_format = str(e))
                 dlg.run()
+                dlg.destroy()
+                self.__flush_gtk_events()
                 return
         else:
             try:
@@ -234,6 +237,8 @@ class Setup(object):
                         buttons = gtk.BUTTONS_CLOSE,
                         message_format = str(e))
                 dlg.run()
+                dlg.destroy()
+                self.__flush_gtk_events()
                 return
         data[DATA_STARTED] = not data[DATA_STARTED]
 
@@ -293,12 +298,12 @@ class Setup(object):
 
         langs = dict()
 
-        for name, lang, icon, author, credits, _exec, started in self.__bus.register_list_engines():
+        for name, local_name, lang, icon, author, credits, _exec, started in self.__bus.register_list_engines():
             _lang = ibus.LANGUAGES.get(lang, "other")
             _lang = _(_lang)
             if _lang not in langs:
                 langs[_lang] = list()
-            langs[_lang].append([name, lang, icon, author, credits, _exec, started])
+            langs[_lang].append([name, local_name, lang, icon, author, credits, _exec, started])
 
         keys = langs.keys()
         keys.sort()
@@ -319,7 +324,7 @@ class Setup(object):
                 COLUMN_DATA, None)
             langs[key].sort()
 
-            for name, lang, icon, author, credits, _exec, started in langs[key]:
+            for name, local_name, lang, icon, author, credits, _exec, started in langs[key]:
                 child_iter = model.append(iter)
                 is_preload = "%s:%s" % (lang, name) in self.__preload_engines
 
@@ -328,13 +333,13 @@ class Setup(object):
                     pixbuf = pixbuf_missing
 
                 model.set(child_iter,
-                    COLUMN_NAME, name,
+                    COLUMN_NAME, local_name,
                     COLUMN_ENABLE, started,
                     COLUMN_PRELOAD, is_preload,
                     COLUMN_VISIBLE, True,
                     COLUMN_ICON, pixbuf,
                     COLUMN_DATA,
-                    [name, lang, icon, author, credits, _exec, started, is_preload])
+                    [name, local_name, lang, icon, author, credits, _exec, started, is_preload])
 
         return model
 
index d8d1c9d..25e2c6b 100644 (file)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.4 on Thu Aug 21 13:47:06 2008 -->
+<!--Generated with glade3 3.4.4 on Fri Aug 22 11:28:43 2008 -->
 <glade-interface>
   <widget class="GtkDialog" id="dialog_setup">
     <property name="border_width">5</property>
@@ -20,6 +20,7 @@
             <child>
               <widget class="GtkVBox" id="vbox2">
                 <property name="visible">True</property>
+                <property name="spacing">2</property>
                 <child>
                   <widget class="GtkCheckButton" id="checkbutton_auto_start">
                     <property name="visible">True</property>
                             <property name="n_rows">3</property>
                             <property name="n_columns">3</property>
                             <child>
-                              <widget class="GtkButton" id="button_prev_engine">
+                              <widget class="GtkLabel" id="label7">
                                 <property name="visible">True</property>
-                                <property name="sensitive">False</property>
-                                <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="label" translatable="yes">...</property>
-                                <property name="response_id">0</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">Trigger:</property>
+                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
                               </widget>
                               <packing>
-                                <property name="left_attach">2</property>
-                                <property name="right_attach">3</property>
-                                <property name="top_attach">2</property>
-                                <property name="bottom_attach">3</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkButton" id="button_next_engine">
+                              <widget class="GtkEntry" id="entry_trigger">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
-                                <property name="receives_default">True</property>
-                                <property name="label" translatable="yes">...</property>
-                                <property name="response_id">0</property>
+                                <property name="editable">False</property>
                               </widget>
                               <packing>
-                                <property name="left_attach">2</property>
-                                <property name="right_attach">3</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>
                                 <property name="y_padding">4</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkEntry" id="entry_prev_engine">
+                              <widget class="GtkLabel" id="label8">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="editable">False</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">Next engine:</property>
+                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
                               </widget>
                               <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">2</property>
-                                <property name="bottom_attach">3</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>
                                 <property name="y_padding">4</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkEntry" id="entry_next_engine">
+                              <widget class="GtkLabel" id="label9">
                                 <property name="visible">True</property>
-                                <property name="can_focus">True</property>
-                                <property name="editable">False</property>
+                                <property name="xalign">1</property>
+                                <property name="label" translatable="yes">Previous engine:</property>
+                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
                               </widget>
                               <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
+                                <property name="x_options">GTK_FILL</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>
                                 <property name="y_padding">4</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkLabel" id="label9">
+                              <widget class="GtkEntry" id="entry_next_engine">
                                 <property name="visible">True</property>
-                                <property name="xalign">1</property>
-                                <property name="label" translatable="yes">Previous engine:</property>
-                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                                <property name="can_focus">True</property>
+                                <property name="editable">False</property>
                               </widget>
                               <packing>
-                                <property name="top_attach">2</property>
-                                <property name="bottom_attach">3</property>
-                                <property name="x_options">GTK_FILL</property>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>
                                 <property name="y_padding">4</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkLabel" id="label8">
+                              <widget class="GtkEntry" id="entry_prev_engine">
                                 <property name="visible">True</property>
-                                <property name="xalign">1</property>
-                                <property name="label" translatable="yes">Next engine:</property>
-                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                                <property name="can_focus">True</property>
+                                <property name="editable">False</property>
                               </widget>
                               <packing>
-                                <property name="top_attach">1</property>
-                                <property name="bottom_attach">2</property>
-                                <property name="x_options">GTK_FILL</property>
+                                <property name="left_attach">1</property>
+                                <property name="right_attach">2</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>
                                 <property name="y_padding">4</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkEntry" id="entry_trigger">
+                              <widget class="GtkButton" id="button_next_engine">
                                 <property name="visible">True</property>
                                 <property name="can_focus">True</property>
-                                <property name="editable">False</property>
+                                <property name="receives_default">True</property>
+                                <property name="label" translatable="yes">...</property>
+                                <property name="response_id">0</property>
                               </widget>
                               <packing>
-                                <property name="left_attach">1</property>
-                                <property name="right_attach">2</property>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="top_attach">1</property>
+                                <property name="bottom_attach">2</property>
+                                <property name="x_options">GTK_FILL</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>
                                 <property name="y_padding">4</property>
                               </packing>
                             </child>
                             <child>
-                              <widget class="GtkLabel" id="label7">
+                              <widget class="GtkButton" id="button_prev_engine">
                                 <property name="visible">True</property>
-                                <property name="xalign">1</property>
-                                <property name="label" translatable="yes">Trigger:</property>
-                                <property name="justify">GTK_JUSTIFY_RIGHT</property>
+                                <property name="sensitive">False</property>
+                                <property name="can_focus">True</property>
+                                <property name="receives_default">True</property>
+                                <property name="label" translatable="yes">...</property>
+                                <property name="response_id">0</property>
                               </widget>
                               <packing>
+                                <property name="left_attach">2</property>
+                                <property name="right_attach">3</property>
+                                <property name="top_attach">2</property>
+                                <property name="bottom_attach">3</property>
                                 <property name="x_options">GTK_FILL</property>
                                 <property name="y_options">GTK_FILL</property>
                                 <property name="x_padding">4</property>