2

I maintain a pluggable Django app that contains translations. All strings in Python and HTML code are written in English. When translating the strings to German, I'm always fighting with the problem that German differentiates between formal and informal speech (see T–V distinction). Because the app is used on different sites, ranging from a social network to a banking website, I can't just support either the formal or informal version. And since the translations can differ quite a bit, there's no way I can parameterize it. E.g. the sentence "Do you want to log out?" would have these two translations:

  • Wollen Sie sich abmelden? (formal)
  • Willst du dich abmelden? (informal)

Is there anything in Gettext that could help me with this?

4

2 回答 2

4

您可以使用上下文标记为您的翻译提供额外的上下文。

logout = pgettext('casual', 'Do you want to log out?')

...

logout = pgettext('formal', 'Do you want to log out?')
于 2013-07-03T20:31:30.993 回答
1

gettext 和 UNIX 在其他类似情况下使用的最佳方法是使用locale variables。例如,sr_RSis(或曾经是,因为如今塞尔维亚语被认为是一种元语言......)用于塞尔维亚语的代码,用西里尔文编写。但它有时也用拉丁文书写,因此sr_RS@latin用作语言名称,当然也用作 MO 文件名或目录。

在这里,看看我在我的系统上提供的一些翻译:

$ find /usr/local/share/locale | grep /sr
/usr/local/share/locale/sr
/usr/local/share/locale/sr/LC_MESSAGES
/usr/local/share/locale/sr/LC_MESSAGES/bash.mo
/usr/local/share/locale/sr/LC_MESSAGES/bfd.mo
/usr/local/share/locale/sr/LC_MESSAGES/binutils.mo
/usr/local/share/locale/sr/LC_MESSAGES/gettext-runtime.mo
/usr/local/share/locale/sr/LC_MESSAGES/gettext-tools.mo
/usr/local/share/locale/sr/LC_MESSAGES/glib20.mo
/usr/local/share/locale/sr/LC_MESSAGES/wget.mo
/usr/local/share/locale/sr@ije
/usr/local/share/locale/sr@ije/LC_MESSAGES
/usr/local/share/locale/sr@ije/LC_MESSAGES/glib20.mo
/usr/local/share/locale/sr@latin
/usr/local/share/locale/sr@latin/LC_MESSAGES
/usr/local/share/locale/sr@latin/LC_MESSAGES/glib20.mo
/usr/local/share/locale/sr_RS
/usr/local/share/locale/sr_RS/LC_MESSAGES
/usr/local/share/locale/sr_RS/LC_MESSAGES/mkvtoolnix.mo
/usr/local/share/locale/sr_RS@latin
/usr/local/share/locale/sr_RS@latin/LC_MESSAGES
/usr/local/share/locale/sr_RS@latin/LC_MESSAGES/mkvtoolnix.mo
$

所以处理德语变体的最佳方法是相同的:使用de(或de_DE)作为基本的非正式变体,并拥有一个单独的翻译文件de_DE@formal,其中包含翻译的正式变体。

这基本上也是 WordPress 所做的。当然,作为 WordPress,它们有自己的特殊风格并且不使用变体语法,而是在文件名中添加了第三个组件:de_DE.mo是非正式的(也是后备的,因为它缺少任何进一步的规范)变体并de_DE_formal.mo包含正式的变体。

于 2016-11-06T09:23:57.387 回答