我正在使用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"
但我认为无法传递一个或多个变量。这可能吗?
答案 0 :(得分:31)
poedit认识到变种。
msgid "Are you sure you want to block %s?"
msgstr "Sind Sie sicher, dass Sie %s blockieren?"
和PHP
sprintf(_('Are you sure you want to block %s?'),'Alice');