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
- First, determine the two-letter ISO code for the language you are addressing from this page.
- Copy the values folder (app_name > res > values) and paste it at the same level (app_name > res > Copy of values)
- 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 ;-)
- Go to translate.google.com.
- Click on upload a document. Select the default strings.xml from the values folder.
- Select the appropriate languages in the "Translate from" and "Translate into" fields.
- 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
- Copy the output.
- Launch the new strings.xml under the "values-xx" folder you created above.
- 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!

0 comments:
Post a Comment