Symfony为单一语言使用多个翻译文件
我想知道在使用yml文件时,Symfony 3.5是否可以为一种语言使用多个翻译文件 目前我有这样的想法:Symfony为单一语言使用多个翻译文件,symfony,Symfony,我想知道在使用yml文件时,Symfony 3.5是否可以为一种语言使用多个翻译文件 目前我有这样的想法: AppBundle/Resources/translations/messages.en.yml AppBundle/Resources/translations/messages.de.yml 它包含了我所有的两种语言的翻译。但是,我想知道是否可以将其更改为以下结构: AppBundle/Resources/translations/en/products.yml AppBundle/
AppBundle/Resources/translations/messages.en.yml
AppBundle/Resources/translations/messages.de.yml
它包含了我所有的两种语言的翻译。但是,我想知道是否可以将其更改为以下结构:
AppBundle/Resources/translations/en/products.yml
AppBundle/Resources/translations/en/invoices.yml
AppBundle/Resources/translations/de/products.yml
AppBundle/Resources/translations/de/invoices.yml
我一直在寻找,但我一直无法找到某种解决办法。我用它来分割我的路线
AppBundle/Resources/config/routing.yml
appbundle_routes:
resource: '@AppBundle/Resources/config/routing'
type: directory
在该文件夹中,我将所有路线拆分为:
AppBundle/Resources/config/routing/products.yml
AppBundle/Resources/config/routing/users.yml
AppBundle/Resources/config/routing/invoices.yml
我想知道是否有可能在翻译中实现同样的效果?Symfony的
翻译器
要求以domain.locale.loader
格式命名文件。如果您有消息.en.yml
:
是域的默认名称,您还可以指定例如messages
invoices
是语言环境en
正在指定将使用yml
加载程序YAML
AppBundle/Resources/translations/products.en.yml
AppBundle/Resources/translations/invoices.en.yml
当您使用translator时,请指定应在其中查找翻译的域:
$translator->trans('translated.key', [], 'invoices');
或在小树枝中
:
{{ 'translated.key'|trans({},'invoices') }}
Symfony的
翻译器
要求文件以域.locale.loader
格式命名。如果您有消息.en.yml
:
是域的默认名称,您还可以指定例如messages
invoices
是语言环境en
正在指定将使用yml
加载程序YAML
AppBundle/Resources/translations/products.en.yml
AppBundle/Resources/translations/invoices.en.yml
当您使用translator时,请指定应在其中查找翻译的域:
$translator->trans('translated.key', [], 'invoices');
或在小树枝中
:
{{ 'translated.key'|trans({},'invoices') }}
啊,谢谢你提供的信息,我想我会看看这个,或者最终写我自己的翻译服务。啊,谢谢你提供的信息,我想我会看看这个,或者最终写我自己的翻译服务。