Twigjs 和动态翻译
我面临一个问题,我在 Symfony2 twigjs 和 assetic 中使用来动态渲染我的一些模板。
我已经阅读了文档、源代码和测试。
在 TransFilterCompilerTest.php/testCompileDynamicTranslations
中,似乎
{{ 'foo' |我的 twig 模板中的 trans }}
将在 twigjs 模板中替换为 twigjs 中的
'this.env_.filter("trans",'...
但是< /strong> 在我编译的 js 中我只有 sb.append(twig.filter.escape(this.env_, "posted", "html", null, true));
你知道吗为什么?
谢谢!
I'm facing a problem, I use in Symfony2 twigjs and assetic to render some of my templates dynamically.
I've read the doc, the source, and the tests.
In TransFilterCompilerTest.php/testCompileDynamicTranslations
it seems that a
{{ 'foo' | trans }}
in my twig template
would be replaced in the twigjs template by
'this.env_.filter("trans",'...
in my twigjs one
but in my compiled js I only have sb.append(twig.filter.escape(this.env_, "posted", "html", null, true));
Do you have any idea why?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
经过更多调查后,我发现虽然翻译编译过滤器是几个月前在 JMSTwigJsBundle 中添加的,但所需的功能最近才添加到 Assetic 中。使用库的发布版本将不起作用。目前,必须使用 git 的 master。
使用 deps 文件...
必须将站点支持的语言指定为参数。我将其添加到我的 config.yml 文件中。
最后,文件集必须表明它根据区域设置而变化。
为了保证完整性,以下是一个示例模板:
twig.js 引导文件还必须在模板定义之前加载。调用模板正如预期的那样:
After some more investigation, I found out that while the translation compile filter was added several months ago in JMSTwigJsBundle, the required features were only added recently to Assetic. Using the released versions of the libraries will not work. For now, master from git must be used.
Using the deps file...
The languages supported by the site must be specified as a parameter. I added it to my config.yml file.
Finally, the file set must indicate that it varies based on the locale.
Here is a sample template for completeness:
The twig.js bootstrap file must also be loaded prior to the template definitions. Calling a template is as expected: