easy_localization icon indicating copy to clipboard operation
easy_localization copied to clipboard

Ability to get translations for specific locale without changing the application locale

Open Szymon-Gesicki opened this issue 1 year ago • 3 comments

Hello,

I'm working on a Flutter application using Easy Localization. I encountered a scenario where I need to get a translation for a specific locale without changing the application locale.

In my use case, I have a class that receives keys and returns translations. I'd like to be able to provide a locale to this class and have it return translations in that locale, but without changing the global locale of the app. This is used to print receipts which are in a different language than the application language

Currently, it seems that the only way to change the locale of translations is to change the application locale using context.setLocale(). But this affects the entire application and changes translations everywhere, not just in my class.

I could manually load and parse localization files to get translations for a specific locale, but this feels a bit cumbersome and not ideal.

Is there a better way to get translations for a specific locale without affecting the global locale of the app, or could this be a feature to consider adding to Easy Localization?

Thank you in advance for your help!

Szymon-Gesicki avatar Jul 14 '23 09:07 Szymon-Gesicki

I also need this ability, do you get any update?

taichushouwang avatar Jul 21 '23 09:07 taichushouwang

Same here. I tried to use different EasyLocalization widget instances with no luck

muccy-timeware avatar Dec 20 '23 12:12 muccy-timeware