Symfony 2.6 - 翻译不起作用

时间:2015-05-07 08:05:43

标签: php symfony

我已经安装了新的symfony2,我尝试翻译文本,但在调试中:翻译,ID是重复的,twig输出显示我的ID,而不是消息预览文本。有什么问题?

app / console debug:翻译输出:

+----------+-----------+----------------------+
| State(s) | Id        | Message Preview (en) |
+----------+-----------+----------------------+
| x        | base.test | base.test            |
| o        | base.test | This is test         |
+----------+-----------+----------------------+

twig输入:

{% trans %}base.test{% endtrans %}

树枝输出:

base.test

base.en.yml:

base.test: This is test

1 个答案:

答案 0 :(得分:3)

您需要定义翻译域。

<ContentPage.Resources>
    <ResourceDictionary>
        <Color x:Key="Maybe">#ffddbc21</Color>
        <Color x:Key="Yes">#3CB371</Color>
        <Color x:Key="No">#B22222</Color>
        <Color x:Key="Depends">#ffd78800</Color>
    </ResourceDictionary>
</ContentPage.Resources>

<Label Text="{Binding Result}" HorizontalOptions="FillAndExpand" BackgroundColor="{StaticResource {BindingSource Result}}" />

配置你的config.yml:

{% trans from "base" %}base.test{% endtrans %}