有效构建RoR中的翻译的方法? [英] Effective way to structure translations in RoR?

查看:103
本文介绍了有效构建RoR中的翻译的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望有人能仔细看一下,因为我以前从未翻译过英语,所以我不确定是否会存在语法冲突.

I was hoping somebody could look this over, as I've never translated anything but English before, and so I'm not sure if there would be grammatical conflicts.

我有:

en:
  articles:
    name: "Articles"

  comments:
    name: "Comments"

  # things
  no_results: "There are no %{things}"
  my: "My %{things}"

然后在视图文件中,例如:

Then in a view file, for example:

#title= t('articles.name')

%ul
  %li= link_to t('my', things: t('articles.name')), articles_path(user)

.no_results= t('no_results', things: t('comments.name').downcase)

我想做的是干燥我的翻译,但也不会因使用方法而陷入混乱:

What I'm trying to do is DRY up my translations, but also not get into a whole mess with using methods:

  • 复数
  • 单数化
  • 小写
  • 大写

在文本中使用时,模型的最常见形式是大写和复数形式,这就是为什么我选择文章"还是文章"或文章".您是否会喜欢视图文件中的上述方法而不是类似的东西?

It seems the most common form of a model when used in text is capitalized and pluralized, that is why I chose "Articles" vs "Article" or "article". Would you favor the above methods in view files vs something like:

articles:
  one: "Article"
  other: "Articles"

..这可能会发展为混乱局面:

..which might develop into this mess:

articles:
  one:     "Article"
  other:   "Articles"
  one_l:   "article"
  other_l: "articles"

推荐答案

不同的语言对于如何构建句子有不同的规则.干燥您的翻译可能会导致外语语法错误的句子.我建议一次坚持一个逻辑文本块.例如段落,句子,表达方式或单词.

Different languages have different rules for how sentences are built. DRYing up your translations may result in grammatically incorrect sentences in foreign languages. I would suggest sticking to a logical block of text at a time. e.g. paragraph, sentence, expression or word.

例如,您假设希望将您的应用程序翻译成每种语言,单词"my"将始终位于单词"articles"之前,而"my"只有一个单词.

For example you are assuming that in every language that you want your application to be translated into, the word "my" will always come before the word "articles" and that there is only one word for "my".

在某些语言中,我的"的版本可能取决于其附带的词.我会使用保加利亚语,因为我非常了解-我的车"翻译为"Moiata kola",我的卡车"翻译为"Moiat kamion".不是我的"的直截了当的翻译.

In some languages the version of "my" may depend on the word that goes along with it. I'll use Bulgarian because I know it well - "My car" translates into "Moiata kola" and "My truck" translates into "Moiat kamion". Not a straight forward translation of "my".

在某些语言中,您可能还必须说诸如我的文章"之类的词,其中文章"先于我的".您可以将文章"配置为使用不同的语言在我的"之前,但是如果您的翻译中包含多个变量,则可能会出现问题.

Also it may be that in some languages you would have to say something like "Articles of mine" where "articles" comes before "my". You can configure "articles" to come before "my" for different languages, but it might become problematic if your translation contains more than one variable.

我将为每一个单独的行:我的文章",没有文章",我的汽车",没有汽车"等等.

I would have a separate line for each of these: "my articles", "there are no articles", "my cars", "there are no cars" and so on.

这篇关于有效构建RoR中的翻译的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆