简体   繁体   English

PHP Symfony i18n消除歧义

[英]PHP Symfony i18n disambiguation

How can we disambiguate homonyms in Symfony framework i18n? 我们如何在Symfony框架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 translated to different words in another language. 就像“免费啤酒”和“言论自由”中的“免费”一样,需要翻译成另一种语言的不同单词。 Most scripts like Wordpress use contexts for this. 大多数脚本(如Wordpress)为此使用上下文。

I'm considering using some IDs which include section names. 我正在考虑使用一些ID,其中包括节名。 I think using IDs is the right method for i18n anyway. 我认为使用ID是i18n的正确方法。 However I think Symfony i18n doesn't support the usage of ID + defaults, like __('ui:generic:yes','Yes') . 但是我认为Symfony i18n不支持ID +默认值的使用,例如__('ui:generic:yes','Yes') So I'm considering adding a dictionary for English including the IDs I need. 因此,我正在考虑添加包含所需ID的英语词典。

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? 有任何最佳实践,示例,Symfony i18n歧义消除/默认值/上下文参考吗?

I'm using a very similar way in my apps : I use translation keys like this : homepage_main_title . 我在应用程序中使用的方式非常相似:我使用如下翻译键: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. 使用Symfony进行此操作的正确方法是使用目录。

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

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

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