damoiser / qr-bills

Ruby Gem to generate QR-Bills for Swiss payments
BSD 3-Clause "New" or "Revised" License
21 stars 15 forks source link

Cannot override locale :it #2

Closed RandieM closed 3 years ago

RandieM commented 3 years ago

Hello there. Thanks for making this gem available; it is very much needed.

I have a question about locales. I see that you set the locale/language to :it in two places in your code; one is in qr-params.rb with language: "it", and the other one is in qr-bills.rb, where it is passed as the default locale I18n.default_locale = :it. The problem is that I cannot seem to be able to override this locale, unless I comment out the code from qr-bills.rb. Am I missing something?

Ideally, wouldn't the default locale be set in a configuration file, though, instead of the code?

damoiser commented 3 years ago

Hello there, thanks and good to see that this work is helping someone out there ;-)

You have right, my first idea was to use the qr_params to set dynamically the language (get_qr_params[:bill_params][:language]), however I miss to read that value later on. I only used the italian language for this, then I didn't noticed yet a bug.

Did you already tried to set on your app default value for I18n? I would expect that something like that should work and override the value in the gems as well:

config.i18n.default_locale = :en

Otherwise I will take a look a bit more deeper on that and try to find a solution.

damoiser commented 3 years ago

FYI @RandieM thanks of the PR of @alexanderadam this issue should be resolved in v0.3

RandieM commented 2 years ago

Apologies for the (very) late reply. Just confirming that the problem has indeed been fixed.

RandieM commented 2 years ago

I may have spoken a bit too fast. After a closer look, I realised that the QR Bill language was actually random and did not correspond to the one passed inside params. The submitted PR (#11) fixes the problem for me.

damoiser commented 2 years ago

thanks @RandieM for the PRs!