简体   繁体   English

Symfony翻译在生产中不起作用

[英]Symfony Translation Doesn't Work In Production

I have a symfony (2.8) app (Sylius actually) and I'm overriding some parts of the translation from SyliusUserBundle in app/Resources/translations/messages.en.yml (namely, the translation key is sylius.customer.email.unique ) 我有一个symfony(2.8)应用程序(实际上是Sylius),我在app/Resources/translations/messages.en.yml覆盖了SyliusUserBundle的部分翻译部分(即翻译密钥是sylius.customer.email.unique

It works like charm on local dev env, but gives me the key on production. 它就像本地开发环境中的魅力一样,但却给了我生产的关键。 I did clear the cache, multiple times, and it doesn't help. 我多次清除缓存,但没有帮助。

What are other possible causes? 其他可能的原因是什么?

UPDATE Gives the translation found in the SyliusUserBundle for English (as it exists in the original bundle) but gives the key in other languages, where the original bundle doesn't contain the translation. 更新提供在SyliusUserBundle中找到的英语翻译(因为它存在于原始包中),但是以其他语言提供密钥,其中原始包不包含翻译。 So as a summary, it seems that translation files app/Resources/translations/messages.<lang>.yml are not being picked up on prod for some reason. 因此,作为总结,似乎翻译文件app/Resources/translations/messages.<lang>.yml由于某种原因未被提取。

UPDATE 2 I also have discovered that the key with the valid translation is present in this file: app/cache/prod/translations/catalogue.hu_HU.ba674f8d2fd06750dcd7ee5bb021c1b905b518ea.php 更新2我还发现此文件中包含有效翻译的密钥: app/cache/prod/translations/catalogue.hu_HU.ba674f8d2fd06750dcd7ee5bb021c1b905b518ea.php

Moving the keys into separate files: 将密钥移动到单独的文件中:

app/Resources/translations/validators.en.yml
app/Resources/translations/validators.hu.yml

has solved the problem. 解决了这个问题。

(An interesting question is why did it work on my dev env..) (一个有趣的问题是为什么它适用于我的开发环境..)

Did you configure the fallback locale? 您是否配置了回退区域设置?

# app/config/config.yml
framework:
    translator: { fallbacks: [en] }

Try rename your file with messages. 尝试使用邮件重命名文件。 hu .yml and if not work change: hu .yml如果不工作改变:

sylius.locale: hu_HU

to

sylius.locale: hu

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM