-
For now I am setting a default locale (de) in my application.rb, as I am not yet sure how I will implement locales and locale switching in my app.
When I use a URL like localhost:3000?locale=de and the following code, pagy i18n behaves as expected: But now I want to do something like this - however that is not working (pagy shows en, which is the first loaded locale, i. e. it doesn't recognize that it should use de): When I log @pagy_locale, it correctly seems to be set to "de" - why isn't pagy picking that up? What am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 5 replies
-
Not sure I get your problem. Could you explain it explicitly? If I have to guess... maybe the following sentence from the doc may be considered: If the |
Beta Was this translation helpful? Give feedback.
-
So you are saying that it works only when there is a locale param in the request. Maybe. I will be able to check that detail in a few days. Meanwhile, if you just invert the order of the locales hash arguments in the initializer, it should use |
Beta Was this translation helpful? Give feedback.
-
OK, I got a few problems recently. Sorry for the late answer. The easiest and recommended way to work with default Pagy::I18n.load({ locale: 'de' }, { locale: 'en' }) Then you can simply do: before_action { @pagy_locale = params[:locale] } There will be no
It could be a number of things: I should have a minimal example of your case to be able to understand what is going on in your code. |
Beta Was this translation helpful? Give feedback.
-
Thank you. I will implement as per the above. If you want to check out my repository - it's here: https://github.com/tkhobbes/ltb-rails - I don't think I am doing anything special but you might figure out what is going on. Pagination is eg happening on books/index.html.erb. |
Beta Was this translation helpful? Give feedback.
OK, I got a few problems recently. Sorry for the late answer.
The easiest and recommended way to work with default
de
locale is settingde
as the first locale:Then you can simply do:
There will be no
:locale
param forde
, only foren
(and/or any other locale that is not the first default).It could be a number of things: I should have a minimal example of your case to be able to understand what is going on in your code.