0

I'm writing a internationalized desktop program written in Vala where a use an extern JSON file to store a list of languages.

I'm using gettext for l10n so if I get the string from the json file and I do something like _(string_var) I could get the translated string. The problem is that I don't know how can I add the string to the pot file using xgettext or some similar tool.

Any idea??

4

2 回答 2

0

如果工具 jq ( http://stedolan.github.io/jq/ ) 是您的选择,下面可能会起作用;

$ curl -s https://raw.githubusercontent.com/chavaone/gnomecat/master/data/languages.json | jq .languages[43].name
"English"
于 2014-07-28T08:29:58.800 回答
0

我最终使用的解决方案是修改 JSON 文件以仅在我想翻译该字符串时使用双引号字符串。例如:

{
    'code' : 'es',
    'name' : "Spanish; Castilian",
    'pluralform' : 'nplurals=2; plural=(n != 1);',
    'default-team-email': 'gnome-es-list@gnome.org'
}

在上一段 JSON 文件中,我想翻译的唯一字符串是"Spanish; Castillian"。然后在 POTFILES.in 中,我只使用gettext/quoted类型。

# List of source files containing translatable strings.
# Please keep this file sorted alphabetically.
[encoding: UTF-8]
[type: gettext/quoted]data/languages.json
[type: gettext/quoted]data/plurals.json
[type: gettext/glade]data/ui/appmenu.ui

[...]
于 2015-08-18T16:57:25.383 回答