EddyVerbruggen / nativescript-localize

Internationalization plugin for NativeScript using native capabilities of each platform
MIT License
79 stars 31 forks source link

There is a weird side effect while using a WebView #93

Closed emog closed 3 years ago

emog commented 4 years ago

Starting from Android N, there is a weird side effect while using a WebView. For unknown reasons, the very first creation of it resets the application locale to the device default. Therefore, you have to set the desired locale back.

When we navigate to page which has webview and go back to the previous page the locale is changed to the default one. This is native issue but I hope there is some workaround. Do you have any idea how to avoid this. I tried next code but it's not working:

const language = getString('applanguage'); //It's still the selected locale for example "bg" overrideLocale(language) //The UI is not updated with the selected locale. This is added in page loaded event. I tried to remove the applanguage key and to execute overrideLocale(language) but it's still not working.

I it's native issue here: https://issuetracker.google.com/issues/37113860

I saw here a workaround for native(android) but they are using some library for localization https://proandroiddev.com/change-language-programmatically-at-runtime-on-android-5e6bc15c758

emog commented 4 years ago

I found solution myself. Please check my pull request if you have the same problem.