简体   繁体   中英

Translation of “will_paginate” doesn't work. What am I doing wrong?

The basic scheme:

= 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"

But in the output are still the labels called Previous Label and Next Label . What is still wrong? Also, I thought I didn't restart the server... but after restart still the same labels, not my translations

You can grab YAML files translated in various languages for will_paginate here : https://github.com/tigrish/will-paginate-i18n .

In your example, you're overriding the :previous_label and the :next_label, but you're not scoping it to 'will_paginate'.

Either remove the overrides completely and customise the labels in your translation file :

will_paginate @products

or scope the .t calls correctly :

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

you can then change the text of the pagination links by adding the following to config/locales/will_paginate.en.yml:

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

And add following in application.rb

config.i18n.default_locale = :en

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM