1
我無法讓我的i18n在wxPython中加載。這裏是我的文件結構:wxPython i18n not loading
locale
│ lembox.pot
│
├─de_DE
│ └─LC_MESSAGES
│ lembox.mo
│ lembox.po
│
├─en_GB
│ └─LC_MESSAGES
│ lembox.mo
│ lembox.po
│
└─en_US
└─LC_MESSAGES
lembox.mo
lembox.pot
lembox.pot
看起來是這樣的:
# LemBox
# Copyright (C) 2016
# Drew Lemmmy <[email protected]>, 2016.
#
msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"POT-Creation-Date: 2016-01-23 23:27+GMT Standard Time\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <[email protected]>\n"
"Language-Team: LANGUAGE <[email protected]>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: ENCODING\n"
"Generated-By: pygettext.py 1.5\n"
樣本.po文件看起來是這樣的:
# SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR ORGANIZATION
# FIRST AUTHOR <[email protected]>, YEAR.
#
msgid ""
msgstr ""
"Project-Id-Version: LemBox\n"
"POT-Creation-Date: 2016-01-23 23:44+0000\n"
"PO-Revision-Date: 2016-01-23 23:45+0000\n"
"Last-Translator: \n"
"Language-Team: \n"
"Language: de_DE\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: pygettext.py 1.5\n"
"X-Generator: Poedit 1.8.6\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Poedit-Basepath: ..\n"
"X-Poedit-SearchPath-0: lembox.py\n"
"X-Poedit-SearchPath-1: main_app.py\n"
"X-Poedit-SearchPath-2: utility.py\n"
"X-Poedit-SearchPath-3: hash_util.py\n"
#: hash_util.py:13
msgid "hash_shortcut"
msgstr "Hash bilden"
#: hash_util.py:16
msgid "hash_title"
msgstr "Hashbildung"
#: main_app.py:37
msgid "exit"
msgstr "Beenden"
#: main_app.py:45
msgid "LemBox"
msgstr "LemBox"
#: utility.py:21
#, python-format
msgid "LemBox - %s"
msgstr "LemBox - %s"
#, fuzzy
#~ msgid "Hash"
#~ msgstr "Hash"
在我的代碼,我喜歡加載的語言環境所以:
def main():
app = wx.App(False)
locale = wx.Locale()
locale.AddCatalogLookupPathPrefix('.')
locale.AddCatalog('de_DE')
app.MainLoop()
當然,使用這樣的文本:_("hash_shortcut")
(當然前面定義了_ = wx.GetTranslation
)。
但是,在我的應用程序中,我看到的是未翻譯的字符串。這裏有什麼問題?
編輯:我在我的應用程序中看到字面意思是「hash_shortcut」,「hash_title」等。
這樣工作,非常感謝! – Lemmmy