基本方案:
= 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 于: will_paginate: page_gap:“......” previous_label:“上一个” next_label:“下一步”
但在输出中仍然是名为Previous Label
和Next Label
的标签。
还有什么问题?另外,我以为我没有重启服务器......但重启后仍然是相同的标签,而不是我的翻译
答案 0 :(得分:6)
您可以在此处抓取以各种语言翻译的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")
答案 1 :(得分: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