Ruby on rails 3 RoR翻译插值-使用其他翻译的值?

Ruby on rails 3 RoR翻译插值-使用其他翻译的值?,ruby-on-rails-3,Ruby On Rails 3,假设我有这些翻译: en: article: name: "article" 是否可以执行以下操作: test1: "We have zero #article.name.pluralize" test2: "There is an error in your #article.name" test3: "Title for this page is: My #article.name.pluralize.capitalize" 我对1和3不太在意(即对变量执行额外的函数),但是

假设我有这些翻译:

en:
  article:
    name: "article"
是否可以执行以下操作:

test1: "We have zero #article.name.pluralize"
test2: "There is an error in your #article.name"
test3: "Title for this page is: My #article.name.pluralize.capitalize"
我对1和3不太在意(即对变量执行额外的函数),但是test2将是一个很大的帮助


这也回避了一个问题:这是构建翻译文件的好方法吗?我这样问是因为其他语言的结构可以完全不同。我正在想办法使翻译文件干涸。

您可以这样定义翻译:

test1: "We have zero %{things}"
I18n.t(:test1, :scope => [:flashes], :things => t(:name, :scope => [:article] ))
然后,在代码的某个地方,您可以这样使用它:

test1: "We have zero %{things}"
I18n.t(:test1, :scope => [:flashes], :things => t(:name, :scope => [:article] ))
或者,使用不同的符号:

I18n.t("flashes.test1", :things => I18n.t("article.name"))

您可以这样定义翻译:

test1: "We have zero %{things}"
I18n.t(:test1, :scope => [:flashes], :things => t(:name, :scope => [:article] ))
然后,在代码的某个地方,您可以这样使用它:

test1: "We have zero %{things}"
I18n.t(:test1, :scope => [:flashes], :things => t(:name, :scope => [:article] ))
或者,使用不同的符号:

I18n.t("flashes.test1", :things => I18n.t("article.name"))

谢谢这是一种更好的组织方式。关于这一点,我补充了一个单独的问题:如果你愿意看一看,谢谢。这是一种更好的组织方式。关于这一点,我补充了一个单独的问题:如果你愿意看一看。