Skip to content

Commit a5f9bb0

Browse files
Merge pull request EddyVerbruggen#94 from emog/update-readme
EddyVerbruggen#93 - Added troubleshooting for android WebView reseting locale issue
2 parents aa35e41 + b2b525c commit a5f9bb0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,19 @@ constructor(
273273
setTimeout(() => this.changeDetectorRef.detectChanges(), 0);
274274
}
275275
```
276+
### Starting from Android N, there is a weird side effect while using a WebView.
277+
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.
278+
This is native bug and the workaround is
279+
```xml
280+
<WebView url="https://someurl.com" @loaded="webViewLoaded"/>
281+
```
282+
```javascript
283+
import {overrideLocale, androidLaunchEventLocalizationHandler} from "nativescript-localize/localize";
284+
import {getString} from '@nativescript/core/application-settings';
285+
const locale = getString('__app__language__')
286+
287+
function webViewLoaded(){
288+
overrideLocale(locale)
289+
androidLaunchEventLocalizationHandler()
290+
}
291+
```

0 commit comments

Comments
 (0)