问题描述
我正在为我们的网络应用开发多语言支持。我们使用周围的库。除了如何处理包含重要HTML标记的句子的问题之外,所有内容都非常容易。这里有一个简单的例子:
请< a href =/ login />登录< / a>接着说。
以下是我能想到的方法:
-
更改链接以包含整个句子。无论这种变化是否是一个好主意,这种解决方案的问题在于,当两者完全独立时,用户界面会依赖国际化的需求。
-
标记上面的整个字符串以进行翻译(包括格式)。翻译字符串也会直接包含HTML。问题在于,更改HTML格式需要更改所有翻译。
-
紧密结合多个翻译,然后使用字符串插值来组合它们。例如,短语请继续和登录可以单独标记以进行翻译,然后合并。 登录是本地化的,然后包装在HREF中,然后插入到翻译的短语中,这会保留翻译中的%s以标记链接应该到达的位置。这种方法使代码变得复杂,并且打破了翻译字符串的独立性。
b - 主要的翻译工具Trados可以保留标记来自翻译人员的无心腐败。
- 即使标签的内容发生了变化,Trados也可以自动翻译之前看到的文本(但标签的数量及其在这句话是一样的)。翻译者至少会给你一个很好的折扣。
- 样式是区域设置特定的。例如,在某些情况下,大胆的汉语或日语不适用,而东亚语言中的斜体不太常用。翻译者应该有保留或删除样式的自由。
- 单词顺序是特定于语言的。如果要将上面的句子分割成片段,它可能适用于英语和法语,但在中文或日文中,连接时的单词顺序不正确。出于这个原因,最好的做法是将全部句子,而不是句子片段外化。
Change the link to include the whole sentence. Regardless of whether the change is a good idea in this case, the problem with this solution is that UI becomes dependent on the needs of i18n when the two are ideally independent.
Mark the whole string above for translation (formatting included). The translation strings would then also include the HTML directly. The problem with this is that changing the HTML formatting requires changing all the translation.
Tightly couple multiple translations, then use string interpolation to combine them. For the example, the phrase "Please %s to continue" and "log in" could be marked separately for translation, then combined. The "log in" is localized, then wrapped in the HREF, then inserted into the translated phrase, which keeps the %s in translation to mark where the link should go. This approach complicates the code and breaks the independence of translation strings.
- The predominant translation tool, Trados, can preserve the markup from inadvertent corruption by a translator.
- Trados can also auto-translate text that it has seen before, even if the content of the tags have changed (but the number of tags and their position in the sentence are the same). At the very least, the translator will give you a good discount.
- Styling is locale-specific. In some cases, bold will be inappropriate in Chinese or Japanese, and italics are less commonly used in East Asian languages, for example. The translator should have the freedom to either keep or remove the styles.
- Word order is language-specific. If you were to segment the above sentence into fragments, it might work for English and French, but in Chinese or Japanese the word order would not be correct when you concatenate. For this reason, it is best i18n practice to externalize entire sentences, not sentence fragments.
还有其他选择吗?其他人如何解决这个问题?解决方案2就是你想要的。向他们发送整个句子,并嵌入HTML标记。
原因:
I'm developing multi-language support for our web app. We're using Django's helpers around the gettext library. Everything has been surprisingly easy, except for the question of how to handle sentences that include significant HTML markup. Here's a simple example:
Please <a href="/login/">log in</a> to continue.
Here are the approaches I can think of:
Are there any other options? How have others solved this problem?
Solution 2 is what you want. Send them the whole sentence, with the HTML markup embedded.
Reasons:
这篇关于你如何处理带标记的文本翻译?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!