How to do fast localization for Android & iOS
How to do fast localization for Android & iOS?
In our daily development life, Client needs multiple language support for their app. So we have to spend a lot of time to translate strings into multiple languages. It not only for android development but it also for iOS development.
So now it’s time to say bye-bye typical job to convert app to multiple language manually. Google already have formula to translate strings into multiple languages using its Google translation kit.
Android have by default Translations Editor. use this tool when you have an app that supports multiple languages. Translations Editor provides a consolidated and editable view of all of your default and translated app text. so that you can view, manage, and localize all of your string resources in one place. see more details about Translations Editor.
let see on this blog how to do fast localization for android and iOS app.
we are familiar with trivial steps of creating or adding translations by creating separate values folder for individual locale. ex. French, Japan, Germany etc. and creating strings.xml file for Android. Instead of adding translated values to each keys using Translations Editor, we prefer using the automated creation of string resource values from Google Sheets.
The below steps briefs this procedure clearly.
- Open google sheet in browser
- Create a new spreadsheet
- Create 4 columns. Key, English Translation, French Translation (for French) and French Translation Values.
the sheet would look like in the below picture
- French Translation Column will use below formula to create values automatically by reading English Translation column values.
=GoogleTranslate(B3, “en”, “fr”)
- In place of “en” we can use keyword “auto” for auto detecting language.
- Translated String (Android) column aims at creating values that we can directly copy paste in string.xml belonging to ‘values-fr’ folder.
Ex: For “Hello” value will be “Bonjour”.
- This value will be created automatically applying Google Formulas for the cell value.
=”<string name” & “=” & char(34)& A3&char(34) & “>” & C3 & “</string>”
Now copy all values of “Translated String (Android)” column and paste them inside tag string.xml file created under “values-fr” folder.
Similarly, we can add translations for iOS projects also making use of below formula
=char(34)&B3&Char(34)&char(61)&char(34) &C3 &char(34)
We need to add column “Translated String (iOS)” and copy paste above formula in a 1st cell of that column. To add remaining values in the same column follow same drag method.
Get google sheet for above formula.
How to use this sheet?
- Step 1: Make a Copy of this sheet: File->Make a Copy
- Step 2: Keep your key from existing string.xml file in Column 1 (Applicable for Android only)
- Step 3: Keep your English reference String (Applicable for iOS only)
- Step 4: Keep your new translation in column 4 and 5, apply formula for column 3 by drag method
- Step 5: Apply the formula from column 4 for Android and Column 5 for iOS (By Command + Drag)
That’s it… Isn’t it a pretty easy!!!
You can add new columns for different languages using following translator codes for different languages.
Here is translator code for different languages.
Portuguese (Portugal, Brazil)