1

基本方案:

= will_paginate @products, :previous_label => t("previous_label"), :next_label => t("next_label")

de.yml

  will_paginate:
    page_gap: "…"
    previous_label: "word for back"
    next_label: "word for next"

en.yml en: will_paginate: page_gap: "..." previous_label: "previous" next_label: "next"

但在输出中仍然是名为Previous Labeland的标签Next Label。还有什么问题?另外,我以为我没有重新启动服务器...但是重新启动后仍然是相同的标签,而不是我的翻译

4

2 回答 2

6

你可以在这里为 will_paginate 获取翻译成各种语言的 YAML 文件:https ://github.com/tigrish/will-paginate-i18n 。

在您的示例中,您将覆盖:previous_label 和:next_label,但您没有将其范围限定为“will_paginate”。

完全删除覆盖并自定义翻译文件中的标签:

will_paginate @products

.t正确确定调用范围:

will_paginate @products,
  :previous_label => t("will_paginate.previous_label"),
  :next_label     => t("will_paginate.next_label")
于 2012-10-17T08:53:55.227 回答
4

然后,您可以通过添加以下内容来更改分页链接的文本config/locales/will_paginate.en.yml:

en:
  will_paginate:
    page_gap: "…"
    previous_label: "previous"
    next_label: "next"

并添加以下内容application.rb

config.i18n.default_locale = :en
于 2012-10-16T09:59:27.700 回答