【问题标题】:symfony : how to translate a string with a tag which order changes according to the languagesymfony:如何翻译带有标签的字符串,该标签的顺序根据语言而变化
【发布时间】:2015-06-26 08:58:32
【问题描述】:

在我的 symfony 应用程序中,我想翻译字符串“professional recipes”,并将强标签应用于“professional”

问题是法语翻译的顺序相反“recettes professionalnelles”

现在,我不想在我的翻译文件中保留标签,将代码留给程序员,将翻译留给翻译人员。

我该如何解决这个问题?

【问题讨论】:

    标签: php symfony translation


    【解决方案1】:

    不要认为这是可能的,因为翻译文件是唯一知道强词的上下文/位置的文件。如果您使用 Twig,这可以通过输出原始翻译来完成:

    {{ 'professional_recipes'|trans|raw }}
    

    您的翻译文件:

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

    【讨论】:

      猜你喜欢
      • 2014-07-05
      • 1970-01-01
      • 2017-03-07
      • 2021-05-07
      • 2014-09-11
      • 2011-10-23
      • 1970-01-01
      • 2022-06-25
      • 2019-06-24
      相关资源
      最近更新 更多