简体   繁体   English

Symfony 和 Twig - JMS i18n 仅从标签中提取而不是过滤器

[英]Symfony and Twig - JMS i18n is only extracting from tags but not filter

In a Symfony web app, I have the JMS i18n stuff for translation installed.在 Symfony Web 应用程序中,我安装了用于翻译的 JMS i18n 东西。

If I use it like如果我像这样使用它

{% trans %}layout.name.default{% endtrans %}

And run the extract script it works like a charm.并运行提取脚本,它就像一个魅力。 Exactly as I want it to.正是我想要的。

Unfortunately I need to pass a localized string at some point to a function (a macro in TWIG) and there it doesn't work anymore.不幸的是,我需要在某个时候将一个本地化的字符串传递给一个函数(TWIG 中的一个宏),然后它就不再工作了。

{{ _self.menuItem('layout.navigation.home'|trans(), path('foo_homepage')) }}

When I run the export with当我运行导出时

php app/console translation:extract de --config=app --output-format=xliff
php app/console translation:extract en --config=app --output-format=xliff
php app/console translation:extract fr --config=app --output-format=xliff
php app/console translation:extract it --config=app --output-format=xliff

It just ignores my layout.name.home .它只是忽略了我的layout.name.home How can I make it clear to JMS to read that too?我怎样才能让 JMS 清楚地阅读它?

So it seams that it was just some cached version, it tried to read from.所以看起来它只是一些缓存版本,它试图从中读取。 After deleting the cache manually with rm app/cache/* -rf and rebuild the translation files every thing seams to work.使用rm app/cache/* -rf手动删除缓存并重建翻译文件后,一切正常。

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

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