【发布时间】:2012-10-03 09:02:17
【问题描述】:
我正在使用 PHP 的 gettext。我想翻译一个包含变量的句子。这可能吗?
例如,英文:
Are you sure you want to block Alice?
(其中“Alice”是用户名。)
但是,在德语中,主语不会出现在句末。
Sind Sie sicher, dass Sie Alice blockieren?
在messages.po中,我有
msgid "BLOCK"
msgstr "Are you sure you want to block"
但我看不到传递一个或多个变量的方法。这可能吗?
【问题讨论】:
-
%s和sprintf等占位符通常用于此目的。此外,您不应将 ABBreviations 用于 gettext 源字符串。对未翻译的消息使用简单的英语。消息在实践中很少发生变化,如果发生这种情况,gettext 目录可以很容易地进行调整。
标签: php localization internationalization gettext po