gettext 如何处理 a/an 或 d'/de?
想象一下要翻译的字符串:
“Your path isblocked by a %s”。
如果变量是“anaconda”怎么办?现在应该是“您的路径被 %s 挡住了”。
gettext 如何处理这个问题,或者客户端程序员应该如何处理这个问题,或者其他系统如何处理这个问题?
想象一下这个字符串:
“%s's Page”。
我们想传递“Brian”或“Jim”或“Lucinda”。一切都很好。
但在法语翻译中是:
“Page de %s”。
对于让-保罗或克劳黛特来说这很好,但是可怜的阿奈斯呢?她需要“Page d'Anais”,而不是“Page de Anais”。
gettext 可以处理这个问题吗?标准做法是什么?
Imagine this string for translation:
"Your path is blocked by a %s".
What if the variable is "anaconda". Now it should be "Your path is blocked by an %s".
How does gettext cope with this, or how is the client programmer supposed to cope with this, or how do other systems cope with this?
Imagine this string:
"%s's Page".
We want to pass in "Brian" or "Jim" or "Lucinda". All well and good.
But in the French translation this is:
"Page de %s".
For Jean-Paul or Claudette this is fine but what about poor Anais? She needs "Page d'Anais", not "Page de Anais".
Does gettext cope with this? What's the standard practice?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如您所期望的,gettext 不会帮助您构建语法正确的字符串。即使您没有英语问题,以编程方式构建显示文本也是本地化的一大禁忌,因为可能会出现特定于语言的问题。如果可以管理,您可能应该为每种情况设置单独的字符串,例如“您的路径被恐龙挡住了”,“您的路径被兔子挡住了”,“您的路径被蟒蛇挡住了”等。这意味着很多重复,但翻译系统通过使用翻译记忆库甚至在更复杂的情况下自动翻译(译者只需要在需要时校对和修改)来帮助自动化该过程。
您的“Page d'Anais”/“Page de Claudette”就是一个很好的例子。在这种情况下,唯一的解决方案是将格式字符串存储在可本地化的字符串表中(听起来您已经在这样做),以便本地化人员可以提出可行的解决方案。 (例如“Page de : Anais”,尽管在每种情况下都不是很漂亮,因此他们会将“%s 的页面”本地化为“Page de : %s”)。但本地化人员确实需要了解此格式字符串将去往何处以及它是如何构造的,因此您需要明确这一点。
最广泛误译的字符串之一是“%n of %n”(用于打印页面,如“第 1 页,共 4 页”),如果没有上下文,它通常会被完全错误地翻译。例如,在法语中,直译是“1 de 4”,在这种情况下毫无意义,应该是“1 sur 4”。
As you expect, gettext does not help you build grammatically-correct strings. Even when you don't have problems in English, constructing display text programmatically is a big localizability no-no as language-specific issues may crop up. If it's manageable you should probably have separate strings for each case, such as "Your path is blocked by a dinosaur", "Your path is blocked by a bunny", "Your path is blocked by an anaconda" etc. It means plenty of duplication, but translation systems help automate the process through the use of translation memories and even in the more sophisticated cases automatic translation (which translators just need to proofread and amend if needed).
Your "Page d'Anais"/"Page de Claudette" is a great example. The only solution in such cases is to store the format string in the localizable string table (and it sounds like you are already are doing that) so that localizers can come up with a workable solution. (for example "Page de : Anais" albeit not very pretty works in every case, so they will localize "%s's Page" as "Page de : %s"). But localizers do need to understand where this format strings will go and how it's constructed, so you need to make this clear.
One of the most widely mistranslated strings is "%n of %n" (used for printing pages, as in page "1 of 4") which without context is often translated completely wrong. E.g. in French a literal translation is "1 de 4" which is meaningless in this context, it should be "1 sur 4".