Getting your Android App to speak German (or any other language)

I have localized a couple of apps to German now from the original English. It is a pretty painless experience, but I will just go over the main things that I did to help you on your way.

Some Korean
Firstly I am using Google translate for all of my translations. I speak some German, so this is not a huge leap, but I would be a bit worried about trusting it completely for a language with which I did not have any familiarity. Korean anybody?

Next you create an alternative strings.xml file which will contain your translations. Any that you leave out of this will just revert to the default ones - English in my case. Not a disaster - your app won't crash for example, but certainly not ideal for customer retention, never mind delight.

Next any assets that need to be different for the new locale need to be created. Images obviously spring to mind and are simple, but there are other assets which you will need to take care of. More on those later.
English version
So where you have an images folder called drawable-hdpi you need to create a parallel folder called drawable-de-hdpi, where de is the country code of the new locale you are supporting. Then just fill that folder with the German images and Android takes care of the rest.

Those 'other' localizable assets that I mentioned were html pages for me. I use html for my help files. Nice and easy to format, edit etc. and they allow you to send someone to the web for more info with the minimum of upset.

So I used this code anywhere I wanted to refer to the German html:

Locale locale = Locale.getDefault();
Locale german = new Locale("de", "DE");
if (locale.equals(german)) {
mWebView.loadUrl("file:///android_asset/help-de.html");
} else {
mWebView.loadUrl("file:///android_asset/help.html");
}


The html files themselves just go directly into assets like this:
assets/help.html
assets/help-de.html

The German one
Oddly my phone only has about 5 locales and German was not one of them. This handy app gives you a whole bunch of other locales and is easy to use - and indeed free. So download your app, switch the locale and see it go all German on you. Be careful here if you are localizing to Korean as stated above. This is the locale for your entire phone. Bit awkward to call mammy if its all gone squiggly.


Resources:
You can find my app - which is called Pedometer Log - here. It works in German too :)
The full Google tutorial on Localization can be found here. It's detailed, but well worth doing if you are taking your foreign users seriously.
The details of how Localization works can be found here.

Comments

Popular posts from this blog

Building a choropleth map for Irish agricultural data

Early Stopping with Keras

AutoCompleteTextView backed with data from SQLite in Android