开发者

PHP Symfony i18n disambiguation

How can we disambiguate homonyms in Symfony framework i18n?

It's when we have the same English word used for different meanings, and it should be translated to different words in different points. Like 'free' as in 'free beer' and as in 'free speech', and needs to be translate开发者_如何学JAVAd to different words in another language. Most scripts like Wordpress use contexts for this.

I'm considering using some IDs which include section names. I think using IDs is the right method for i18n anyway. However I think Symfony i18n doesn't support the usage of ID + defaults, like __('ui:generic:yes','Yes'). So I'm considering adding a dictionary for English including the IDs I need.

Any ideas for a more appropriate way (officially or widely accepted) to do this? Any best practices, samples, reference for Symfony i18n disambiguation / defaults / context?


I'm using a very similar way in my apps : I use translation keys like this : homepage_main_title . And I use a dictionary for English : this way, I can spot untranslated text even if I'm browsing the site in english.


A proper way to do this with Symfony is to use the catalogues.

<?php
  echo __('your message',array(),'catalogname');
?>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜