Search code examples
androidmultilingual

Multiple language support on android?


How can I in my android apps allow for several languages in the easiest way possible? I have seen bigger projects use xml files, and the coding of those isn't hard, but I can't seem to integrate it into the code. The other way which is actually very tricky is using booleans but that would require several languages from the start, and I can only supply 2 at this point.

The languages have to be easy to integrate at a late state, so it doesn't require changing several thousand lines, but the initial work has to be done in an early state(the late state integration is for the languages, the early is for support of it)

I'm using android studio


Solution

  • You should read the documentation. It's surprisingly very easy to incorporate multiple languages in your app as you just need to move all your strings into values/strings.xml and then provide other languages with the same string ids but different values at values-[LANGUAGE_ISO_CODE]/strings.xml.

    Example

    values/strings.xml

    <resources>
        <string name="app_name">Something</string>
    </resources>
    

    For Arabic language

    values-ar/strings.xml

    <resources>
        <string name="app_name">شئ</string>
    </resources>