开发者

Symfony/Doctrine: Fallback to default culture for i18n content

I am building a multilingual website with Symfon 1.4/Doctrine, having English language defined as primary. Content translation in other languages are added gradually, and there will very often be situations when translation of the content requested will be unavailable in requested language. I want to display the requested content in English in those cases. Is this achievable at global level, e.g. for all the i18n content?

As pointe开发者_如何学God by Grad van Horck, this works fine by default for interface translation. What I need is the same functionality for content stored in DB (models having "actAs i18n" behavior).


The default way allows perfectly for this. Just make sure all your texts are in English by default, and translate them where needed. So just do <?php echo __('Hello'); ?>, and then translate it if you want. If a translation can't be found, it just falls back at it's 'original'.

To do the same in your database, you'd probably be best of copying the i18n behaviour (Template/Listener) and add your own bit of logic to fall back on English.


It's possible to set the default culture on sfDoctrineRecord (see http://trac.symfony-project.org/ticket/5458)

sfDoctrineRecord::setDefaultCulture('nl'); // default = 'en'

This changes the i18n fallback when the translation isn't available in the database.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜