0
votes

Android Wear system supports just few languages. Is there a way, how to force resource manager to use resources for languages, which I set up in my mobile phone but they are not supported by Android Wear system?

Example

In my Android Wear app I want support three languages. English, gernam and czech. In my Android Wear application, I have these directories with string files: values, values-de, values-cs.

If I set up in my phone language to german, my Android Wear application correctly use german strings. But if I set up czech language in my mobile phone, Android Wear application use default (from directory: values) strings.

Is there any way, how can I achieve that resouce manager would use values-cs folder when my phone has czech language but czech is not supported by Android Wear system?

Thank you in advance.

EDIT

I did quite ugly workaround. I have service in my mobile phone app which is related to this wear app. When start my wear app, I just ask the phone what language it use. After it send me response, i just try to switch locale in my Xamarin Android Wear app.

Code for change locale:

myLocale = new Java.Util.Locale(lang);
DisplayMetrics dm = Resources.DisplayMetrics;
Configuration conf = Resources.Configuration;
conf.Locale = myLocale;
Resources.UpdateConfiguration(conf, dm);

where lang is ISO639-1 code and myLocale is activity property of type Locale.

1

1 Answers

0
votes

As mentioned in Localization Tips,

If an application is missing even one default resource, it will not run on a device that is set to an unsupported locale. For example, the res/values/strings.xml default file might lack one string that the application needs: When the application runs in an unsupported locale and attempts to load res/values/strings.xml, the user will see an error message and a Force Close button.

For additional information, you may want to also check Language and Locale. It explains the resource resolution strategy in versions of Android lower that 7.0 (API level 24). Next, it describes the improved resource-resolution strategy in Android 7.0. Last, it explains how to take advantage of the expanded number of locales to support more multilingual users.

Furthermore, as mentioned in the given documentation,

When your Java code refers to strings, the system would load strings from the default (en_US) resource file, even if the app has Spanish resources localized under es_ES. This is because when the system cannot find an exact match, it continues to look for resources by stripping the country code off the locale. Finally, if no match is found, the system falls back to the default, which is en_US.

As clearly stated, it's not possible that you use an unsupported locale. So, if you still prefer to use Czech language, you may want to use Android 5.0 or lower version wherein Czech language is supported as shown in this related SO post and in list of Android Supported Language and Locales.