Questions tagged «localization»

1
如何从/ opt进行Glade加载翻译
我已经创建了一个我想通过Ubuntu应用程序开发人员流程提交的应用程序。该过程的要求之一是,安装后,所有文件都进入该/opt/extras.ubuntu.com/<appname>目录。 通过更改包装并在其他人的帮助下,我已经实现了这一点,但是现在我面临着一个新问题:/opt从应用程序运行时,我的翻译未加载。 将会发生以下情况:除非另有说明,否则包含应用程序翻译的二进制文件(MO文件)是从/usr/share/locale(或在Ubuntu的情况下是从/usr/share/locale-langpack)加载的,但是由于/opt需要,在我的应用程序中将它们安装在/opt/extras.ubuntu.com/qreator/locale。 从理论上讲,这很好,因为gettext允许指定替代位置来加载翻译,因此我添加了bindtextdomain调用以实现这一点: import gettext from gettext import gettext as _ gettext.bindtextdomain('qreator', '/opt/extras.ubuntu.com/qreator/share/locale/') gettext.textdomain('qreator') 在某种程度上可以很好地工作:在命令行上输出的所有消息随后都按预期显示。但这并不能解决主要问题:从UI Glade加载翻译需要再次指定翻译域(与gettext.textdomain('qreator')上面的调用等效),但是它不允许指定从何处加载翻译(即Glade等于bindtextdomain,遗憾的是不存在)。这是我正在使用的代码的一部分: builder = Gtk.Builder() builder.set_translation_domain('qreator') # There isn't a way to tell glade to load translations from # somewhere else than /usr/share/locale here builder.add_from_file(ui_filename) 从本质上讲,这意味着如果您的应用安装在中,则无法加载UI的翻译/opt。 在这一点上,我几乎陷入了困境。关于如何从Glade /opt/extras.ubuntu.com/qreator/share/locale/而不是Glade加载翻译的任何想法/usr/share/locale?
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.