Tinwala.com > Blog

Wednesday, July 21, 2010

Quick Tip: Application Localization using Google Translate

Here's a quick tip for localizing your applications on the Android platform. Usually, resources such as strings are stored in a "strings.xml" file and are referenced from layout files and dynamically from code. Since the strings are decoupled from the main application, multiple files for each language can be generated. Here's what that may look like depending on how many languages you choose to support.




Okay. So you have the required folder structure. If the user's locale does not match any of the one's provided, the system defaults to the "values" folder. It's important to note that these are defaults for the user's device and not for the programmers convenience. So make sure the application has reasonable defaults that address your main target market. For instance, if you're releasing an application for the Japanese market, you can have Japanese default values in "values > strings.xml".

On to translating this stuff. Once you have your application built with all resources coded in, it's time to customize the application for different languages. Here are the steps:

Creating the folder structure
  1. First, determine the two-letter ISO code for the language you are addressing from this page.
  2. Copy the values folder (app_name > res > values) and paste it at the same level (app_name > res > Copy of values)
  3. Rename the copied folder to "values-xx" where xx are the two letters you obtained from step 1 above. (Example: values-fr for French)
Translating your lingo

Great. With folder structure out of the way, we can focus on getting some work done ;-)
  1. Go to translate.google.com.
  2. Click on upload a document. Select the default strings.xml from the values folder.
  3. Select the appropriate languages in the "Translate from" and "Translate into" fields.
  4. Click Translate.
Conveniently, Google ignores translating the XML tags and only translates the strings. However, the leading xml tags are ignored and are missing in the output.

Final steps
  1. Copy the output.
  2. Launch the new strings.xml under the "values-xx" folder you created above.
  3. Paste the copied output into the file and save it.
Disclaimer: Of course, this is a quick and dirty trick for translating short and simple phrases. But remember, these strings are often used in your application's interface. So, if Google's translation software screws up, it looks like a blemish on your application. So, for best results, try to find someone to confirm if the translation meets your needs. There are many ways to do this. Many people in your social network are bound to know various languages and they can definitely help. The advantage is that they don't have to do any translation for you. Instead, they just have to check and correct, decreasing their burden.

Happy localizing!

Saturday, July 17, 2010

AppInventor Toggle Version 2.0

Update: Version 2.6 is out. Now features cable detection and auto toggle.



Main screen and settings for cable detection

Visit the project page for download links and more details.

Wednesday, July 14, 2010

AppInventor Toggle for AppInventor (Android)

Update: New version out. Visit the application page for details.


AppInventor. The concept of letting anyone make applications using drag and drop is promising. Unfortunately, it will be a while before a large number of good apps actually make it out of the AppInventor platform. AppInventor is still in its beta release with limited support. So, if you're planning on developing with it, make sure you check out what it can and cannot do.

Getting AppInventor to work on your Android powered device involves setting up your computer and your phone. Although both setups are trivial, the phone setup is annoying because of the different menus that you need to dig through to enable/disable specific settings. So came the birth of my first Android application - a simple toggle for one click enabling/disabling of these settings: AppInventor Toggle.


I've tested the application with a Google ION running 1.6 and various hardware configurations on the emulator. The software is ad-free and available as a free download on the market and various other app stores. Do give it a shot if you use AppInventor and let me know if it helps. 

Links