1

I've an android app with possibility to choose it's language on the main screen (there are a lot of languages including English as default). But starting from Android 7 (when LocaleList appeared) i got a bug: one part of strings is in one language and another part is in the other language.

Example: 1. In Android's language settings are chosen French (as system default) and English; 2. In the app i choose English language; 3. As a result, the whole app's strings are divided into two parts: the first is in English (mostly content, some menu's etc), the second is in French (most of the titles, some drop-down menus, some words in content);

I've got in my BaseActivity overridden onConfigurationChanged method, where i set the user's preferred language (stored in my LanguageManager's static field) as the default locale, which was working well before Android 7 (this was necessary to avoid language change to Android system's after screen rotation).

I've tried to change LocaleList at any possible time to store only the user's preferred language. But it gets updated from Android's system, containing all languages selected in Android's language settings with the system's language in the first place. LocaleList.setDefault doesn't work here.

I've tried to implement all possible solutions found with google like the following ones and nothing worked for me:

In general, my code implements all localization techniques and was working well before LocaleList appeared (except for rotating screen). So, how i see the problem: somewhere in Android's code there is a system locale (list) stored, which is being used all the time. That's why all my intentions to change things has no success.

Antos
  • 23
  • 4
  • please show how you change LocaleList – Maksim Ostrovidov May 16 '18 at 07:29
  • I've tried setDefault and creating a new one with LocaleList constructor with both replaced order of locales and only one in an array. The thing is that ihis doesn't affect anything: changed LocaleList goes further, but later i see that the original one is used again. – Antos May 17 '18 at 08:02
  • Do you utilize `context.createConfigurationContext(config)` (config with changed locale) in `attachBaseContext` of your base activity? – Maksim Ostrovidov May 18 '18 at 08:57
  • Yes. But after i change device's orientation, in my app's main class overridden onConfigurationChanged receives Configuration, which has unchanged LocaleList. Neither it takes in the app any effect. The best result i could achieve was most strings are in the right locale and only few activities' titles in wrong locale. – Antos May 21 '18 at 07:53

0 Answers0