diff options
| author | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-22 12:01:56 +0800 |
|---|---|---|
| committer | Huang Peng <shawn.p.huang@gmail.com> | 2008-08-22 12:01:56 +0800 |
| commit | eab834d3bfc704c4e2f80200914c32696177b120 (patch) | |
| tree | 9779fb0c0187154b10663c48b643916852ae988c | |
| parent | 8bb2ae1cd7a80d7d9a9fbeb9317ca302b202e10a (diff) | |
| download | ibus-eab834d3bfc704c4e2f80200914c32696177b120.tar.gz ibus-eab834d3bfc704c4e2f80200914c32696177b120.tar.xz ibus-eab834d3bfc704c4e2f80200914c32696177b120.zip | |
internationalize engine's name
| -rw-r--r-- | daemon/register.py | 19 | ||||
| -rw-r--r-- | ibus/interface/iibus.py | 2 | ||||
| -rw-r--r-- | po/zh_CN.po | 10 | ||||
| -rw-r--r-- | setup/main.py | 17 | ||||
| -rw-r--r-- | setup/setup.glade | 113 |
5 files changed, 89 insertions, 72 deletions
diff --git a/daemon/register.py b/daemon/register.py index 73a6a6d..29fa8c7 100644 --- a/daemon/register.py +++ b/daemon/register.py @@ -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 diff --git a/ibus/interface/iibus.py b/ibus/interface/iibus.py index fd43678..8fd3d2f 100644 --- a/ibus/interface/iibus.py +++ b/ibus/interface/iibus.py @@ -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() diff --git a/po/zh_CN.po b/po/zh_CN.po index 2652a91..48c1674 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -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 "请按一个键盘按键(或者一个组合按键)" diff --git a/setup/main.py b/setup/main.py index e9cf7c4..b4eeb74 100644 --- a/setup/main.py +++ b/setup/main.py @@ -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 diff --git a/setup/setup.glade b/setup/setup.glade index d8d1c9d..25e2c6b 100644 --- a/setup/setup.glade +++ b/setup/setup.glade @@ -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> @@ -49,19 +50,13 @@ <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> @@ -69,51 +64,46 @@ </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> @@ -137,59 +127,70 @@ </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> |
