如何国际化元数据,例如view.yml中的title? [英] How to internationalize metas such as title in view.yml?

查看:121
本文介绍了如何国际化元数据,例如view.yml中的title?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想国际化我的view.yml的字符串,我找不到如何做到这一点.

I'd like to internationalize the strings of my view.yml, I can't find how to do this.

我认为有一个不好的解决方案:

I have a solution that is bad, in my opinion:

metas:
  title: <?php echo sfContext::getInstance()->getI18n()->__('TITLE'); ?>

我想找到一种方法,而无需调用"sfConfig :: getInstance()".有可能吗?

I'd like to find a way to do it without calling "sfConfig::getInstance()". Is it possible?

推荐答案

永远不要在配置文件中将sfContext用于I18n!在这种情况下,请在View(而不是控制器)中使用setTitle函数

Never ever use sfContext for I18n in Configuration-Files! In such a case use the setTitle function in the View (not the controller)

<?php $sf_response->setTitle(__('TITLE'));?>

这篇关于如何国际化元数据,例如view.yml中的title?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆