translate_enum icon indicating copy to clipboard operation
translate_enum copied to clipboard

Unable to pass locale parameter

Open abdallaayman21 opened this issue 2 years ago • 1 comments

I am unable to pass a locale to the translated_enum function. There seems to be no way to set a custom locale.

Example:

irb(main):056:0> @invoice.translated_status
=> "Unpaid"
irb(main):057:0> @invoice.translated_status(locale: :ar)
Traceback (most recent call last):
        1: from (irb):57
ArgumentError (wrong number of arguments (given 1, expected 0))

How can I change the locale without changing the I18n.locale value? If lets say I want to display the value of an enum in two locales at the same time, is there a a way?

abdallaayman21 avatar May 28 '23 14:05 abdallaayman21

How can I change the locale without changing the I18n.locale value? If lets say I want to display the value of an enum in two locales at the same time, is there a a way?

@abdallaayman21 you can use this:

I18n.with_locale(:ar) { @invoice.translated_status } 

abahaggag avatar Aug 26 '23 05:08 abahaggag