Reputation: 177
I have several version of an app in one project. For one version, if the locale of the device is not found (for example, no values-fr for a device in French), I'd like German to be used. For another version, if the locale of the device is not found, I'd like English to be used.
Is there a way to accomplished this other than by overriding the values/strings.xml (which is used as the fallback resource) in each version?
Upvotes: 3
Views: 1565
Reputation: 28238
If there are untranslated resources, they'll fall back to the default file (the file that isn't set with a specific locale). You cannot change that behavior.
However, you can write a library for it, but since it is a library all references to Context#getString
would call the native system which calls the default file and not a specific locale for fallback resources.
Upvotes: 0
Reputation: 36223
I don't believe you can choose a fallback locale for a specific locale that isn't found.
Instead you create a default locale that will always be used for fallback in the values/string.xml.
If the device is set to a locale that your app doesn't have (e.g. values-fr), it will then just use the default values string.xml.
Upvotes: 2