3

我想在 gettext.po文件中以某种方式使用变量,例如:

msgid "ui_settings_connect_text"
msgstr "Connect to another running instance of " APP_NAME

有没有人尝试过这样的事情?

4

2 回答 2

4

在您的.po文件中:

msgid "Connect to another running instance of %s"
msgstr "Connect to another running instance of %s"

在您的应用中:

printf(_("Connect to another running instance of %s"), app_name);
于 2012-06-18T13:25:07.220 回答
0

我也制作了一个预处理器来执行此操作,因为我不认为应用程序代码应该与某些文本是否包含应用程序名称(使用 Tom 的示例)或任何其他翻译片段相关联。

我已经在 github 上提供了源代码并提供了一个 Windows .exe,但如果您不使用 Windows,它将需要 Mono。

https://github.com/Treer/POpp

为了解决 Tom 提出的问题,.po文件如下所示:

msgid "APP_NAME"
msgstr "Tom's app"

msgid "ui_settings_connect_text"
msgstr "Connect to another running instance of {id:APP_NAME}"

应该可以在任何 GUI PO 编辑器中使用。

预处理器就像这样运行:

popp source.po destination.po
于 2014-02-23T13:45:26.380 回答