symfony:如何翻译带有标签的字符串,该标签的顺序根据语言而变化

时间:2015-06-26 08:58:32

标签: php symfony translation

在我的symfony应用程序中,我想翻译字符串“专业食谱”,并将强标记应用于“专业”

问题是法语翻译的顺序是“recettes professionnelles”

现在,我宁愿不在我的翻译文件中保留标签,留下程序员的代码和翻译人员的翻译。

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

Don't think it's possible, because the translation file is the only one that knows the context/position of the strong word. In case you use Twig, this could be accomplished by outputting the raw translation:

{{ 'professional_recipes'|trans|raw }}

Your translation files:

# messages.en.yml
professional_recipes: '<strong>professional</strong> recipes'

# messages.fr.yml
professional_recipes: 'recettes <strong>professionnelles</strong>'