easy_localization
easy_localization copied to clipboard
Title in app bar and label in bottom navigation bar item not translate after setting locale
I use easy localization 3.0.0.
I have a page with a bottom navigation bar and app bar. when I change the current language by: context.setLocale(Locale("he"));

All content changes except the title and the label in bottom navigation bar until I press one of the icons in the bottom navigation.
I have seen similar problems and none of them helped me come up with a solution:/
i am facing the same issue
I am facing same issue
@aissat I noticed you closed this old issue: https://github.com/aissat/easy_localization/issues/108 Do you know if there is a fix for this issue?
I was able to resolve it
I was able to resolve it
Can you tell me how you do it?
Any solutions?
I found the problem with me. When I used the bottom navigation, the page menu tab had the widget: const menuScreen()
When I remove the const word it worked great
Please post the code you used, or a minimal sample, so we can reproduce the behavior and show how to fix it.
My solution is adding a Locale constructor argument to bottom navigation's wrapper Widget, give it the value of context.locale, so when context.locale changed, bottom navigation will be re-rendered.
But it seems not the best way, hope the team offer us the official solution.
@kevinat did you try using context.tr() instead of just tr()?
@bw-flagship I just tried using context.tr(), it works. Thank you for helping.
And I found wherever I put JUST ONE context.tr(''), or ''.tr(context: context) in bottom navigation's build function, even with an empty string, all other String.tr() or tr(String) works. It's little odd, and only bottom navigation has this issue by far.
Anyway I'm now using your suggestion in my project, instead of passing Locale argument.
@kevinat Nice to hear that it works!
I created #660 to clarify in the readme that context.tr() is the way to go for build methods.
Closing this one.