用源语言翻译 XLIFF 字符串不起作用
如您所知,应用程序字符串经常更改。我为解决这个问题所做的就是在我看来使用“唯一密钥”,然后通过 XLIFF 文件提供翻译。
默认区域性为 en_US,其他支持的区域性包括 hi_IN 我有“en”&我的“app/I18n”中包含 messages.xml 的“hi”文件夹
视图中的字符串看起来像 __('en str')
同样可在 en XLIFF 中找到但是
<file source-language="EN" target-language="en" datatype="plaintext" original="messages" date="2010-08-09T09:35:50Z" product-name="messages">
....
<trans-unit id="xx">
<source>en str</source>
<target>string in english</target>
</trans-unit>
,这不适用于默认区域性/源语言,即 en 这对于印地语来说效果很好。
有什么线索吗?难道我们不允许从源语言翻译成源语言吗?
此外,当显示未翻译的字符串时,它不会在代码读取时被包装在
[T] [/T]
中 (只是尝试了解我可以从这里了解什么: http://trac.symfony-project.org/browser/branches/1.2/lib/i18n/sfI18N.class.php)
谢谢
as you are aware, application strings change quite often. What I have done to solve this is I'm using a 'unique key' in my view, and then providing translations via a XLIFF file.
Default culture is en_US, other supported cultures include hi_IN
I have 'en' & 'hi' folders with messages.xml in my 'app/I18n'
A string in the view looks like __('en str')
same is available in the en XLIFF as
<file source-language="EN" target-language="en" datatype="plaintext" original="messages" date="2010-08-09T09:35:50Z" product-name="messages">
....
<trans-unit id="xx">
<source>en str</source>
<target>string in english</target>
</trans-unit>
However, this does not work for the default culture / source-language, which is en
This works fine for Hindi.
Any clues? Are we not allowed to translate from Source to Source language?
Also when an untranslated string is displayed, it doesn't get wrapped within
[T] [/T]
as the code reads
(just tried understanding what I could from here: http://trac.symfony-project.org/browser/branches/1.2/lib/i18n/sfI18N.class.php)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为了使用
untranslated_prefix
和untranslated_suffix
标记,您需要在应用的 Factory.yml 中打开 i18n 的调试模式:apps/frontend/config /factories.yml:
由您决定需要应用到哪个环境。
In order to use the
untranslated_prefix
anduntranslated_suffix
markers, you need to switch on debug mode for i18n in the factories.yml of your app:apps/frontend/config/factories.yml:
it's just up to you to decide which environment this needs to apply to.
翻译成同一种语言是完全可以的这现在对我有用。
我意识到我的 XML 格式不正确:(
为什么我的翻译没有包含在
[T] [/T]
中,我还没有发现It is perfectly OK to translate into the same language & this does work for me now.
I realized that my XML was not well-formed :(
Why my translations are not wrapped in
[T] [/T]
, I'm yet to discover