3
votes

According to developer.android.com, to support multiple languages we should create unique xml files for each language. Their example:

MyProject/
res/
   values/
       strings.xml
   values-es/
       strings.xml
   values-fr/
       strings.xml

Presuming that a single language xml document could have several hundred string entries, the thought that bundling many of these into an app seems unnecessarily heavy.

So are the language xml files compiled into the .apk?

Or does Android have another system for delivering required language content (I am new to the android ecosphere, so I do not know yet how the Android OS interacts with the apps on it).

Typically for websites, language content is stored in a database, and ajax-retrieved as needed.

2
Android does not have another language system.Kristy Welsh

2 Answers

1
votes

By default, yes. All xml files that you have are packed in to the APK. This is so when the user changes the default language from "English" to "French", the language will change in your app as well without the need of a re-download and/or reinstall.

It is however possible to release multiple APKs that are packed with only certain bundles and release them to different demographics through the Google Play store. This is generally good for Drawables which can take up a lot of space that just won't ever get used on the phone that downloads them. So for example, it wouldn't make sense for a low-resolution screen to download an app with XXHDPI resolution assets. Languages are generally not a good idea for the reason above.

1
votes

The XML files are bundled into the APK. So yes, all language files will be installed with the app. See: https://en.wikipedia.org/wiki/Android_application_package (The XML files are in the /res directory).

I'm not aware of another way to translate text within an app, other than to provide the XML files which contain the translated strings, and as you've seen, that's how to do it per the Docs. So no, there doesn't seem to be another way.

However, I have an XML file which contains over 2400 words, and the file only comes to about 90Kb, which isn't that large. Even if you were to support all 16 (or 18) "major" languages, that is still only 1.62 Mb.

Personally, I think that's a small price to pay for international support. Not to mention that was the size of the XML text file. The compiled XML could be smaller.

If that size is still a problem, you could offer a few languages on release, and have the option to download more languages, letting the user specify what he needs.

You could also release separate APKs and base the languages on the where the user may be downloading from.