EddyVerbruggen / nativescript-localize

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

android overrideLocale won't restart app #96

Open wyong95 opened 4 years ago

wyong95 commented 4 years ago

image

The doc stated switch language require to restart the app but _android.foregroundActivity.finish(); just close the app and not restarting the app. How to make it restart the app and change to the language I selected ? After I open back the app again, the language didn't change at all, still default device's language.

I want to change from chinese to english or vice-versa and able to restart the app after changing the language and display the content with the language selected.

Another question, will it be showing english after I change from chinese if I kill the app and reopen again?

P/S: My default device's language is zh-CN.

Nativescript 6.7.8 Angular 8.2.0 tns-android 6.5.0

atifmerghad commented 4 years ago

Try to call : In main.ts file : on(launchEvent, (args) => { if (args.android) { androidLaunchEventLocalizationHandler(); } });

In your function to change language programmatically (ts file. example : example.component.ts) :

changeLanguage(lang){
const localeOverriddenSuccessfully = overrideLocale(lang);
    if (!isIOS) {
      androidLaunchEventLocalizationHandler();
    } else {

    }
}