Posts

Showing posts with the label Localization

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

Image
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 yo...

Themes and styles

Extracting style information from your layout files This is generally a good practice. It allows you to keep layout separate from style which in turn is kept separate from the program logic. Web development has gone this way with HTML, CSS and back end technologies like servlets. Android supports this separation too. The layout information is kept in the layout xml files. Style information can also be kept there, but for a large application this will get cumbersome. For example if you decide to change the font used on your buttons you will have a big search and replace on your hands. If you use separate styles it will just need to be changed in one place. The holy grail of programming . Finally the program logic is kept in the class files (Activities and the like). All nice and organised. A further separation that Android promotes is the removal of static strings from the logic. They are placed in the strings.xml file. This seems a bit long winded at first, but once your application...

Basic localization

Image
By default in Android all of your static text is in a separate file called strings.xml. This lends itself very neatly to localization. I will just look at localization of strings here. Images, currency, time etc. are more complex but also well supported. First create your application as you normally would with your strings in their own xml file. Next using eclipse right click on your project and select New/Android XML file. In the dialog enter strings.xml as the file name (it won't clash with your existing strings it is going in a separate folder). Select 'language' as the resource configuration and enter the 2 letter code that corresponds to the language you are after. de for German in my case. Click finish. Next you need to translate that text. I just took the whole xml file and pasted it into the input box on Google Translate . It does not mess with your ids as they have underscores in them. It translated most of my text into German. The rest I just manually pasted in ...