translate_enum
translate_enum copied to clipboard
Unable to pass locale parameter
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?
How can I change the locale without changing the
I18n.localevalue? 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 }