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.
Formula:
=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.
Formula
=”<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.
Language |
ISO-639-1 Code |
Afrikaans |
af |
Albanian |
sq |
Amharic |
am |
Arabic |
ar |
Armenian |
hy |
Azeerbaijani |
az |
Basque |
eu |
Belarusian |
be |
Bengali |
bn |
Bosnian |
bs |
Bulgarian |
bg |
Catalan |
ca |
Cebuano |
ceb (ISO-639-2) |
Chinese (Simplified) |
zh-CN (BCP-47) |
Chinese (Traditional) |
zh-TW (BCP-47) |
Corsican |
co |
Croatian |
hr |
Czech |
cs |
Danish |
da |
Dutch |
nl |
English |
en |
Esperanto |
eo |
Estonian |
et |
Finnish |
fi |
French |
fr |
Frisian |
fy |
Galician |
gl |
Georgian |
ka |
German |
de |
Greek |
el |
Gujarati |
gu |
Haitian Creole |
ht |
Hausa |
ha |
Hawaiian |
haw (ISO-639-2) |
Hebrew |
iw |
Hindi |
hi |
Hmong |
hmn (ISO-639-2) |
Hungarian |
hu |
Icelandic |
is |
Igbo |
ig |
Indonesian |
id |
Irish |
ga |
Italian |
it |
Japanese |
ja |
Javanese |
jw |
Kannada |
kn |
Kazakh |
kk |
Khmer |
km |
Korean |
ko |
Kurdish |
ku |
Kyrgyz |
ky |
Lao |
lo |
Latin |
la |
Latvian |
lv |
Lithuanian |
lt |
Luxembourgish |
lb |
Macedonian |
mk |
Malagasy |
mg |
Malay |
ms |
Malayalam |
ml |
Maltese |
mt |
Maori |
mi |
Marathi |
mr |
Mongolian |
mn |
Myanmar (Burmese) |
my |
Nepali |
ne |
Norwegian |
no |
Nyanja (Chichewa) |
ny |
Pashto |
ps |
Persian |
fa |
Polish |
pl |
Portuguese (Portugal, Brazil) |
pt |
Punjabi |
pa |
Romanian |
ro |
Russian |
ru |
Samoan |
sm |
Scots Gaelic |
gd |
Serbian |
sr |
Sesotho |
st |
Shona |
sn |
Sindhi |
sd |
Sinhala (Sinhalese) |
si |
Slovak |
sk |
Slovenian |
sl |
Somali |
so |
Spanish |
es |
Sundanese |
su |
Swahili |
sw |
Swedish |
sv |
Tagalog (Filipino) |
tl |
Tajik |
tg |
Tamil |
ta |
Telugu |
te |
Thai |
th |
Turkish |
tr |
Ukrainian |
uk |
Urdu |
ur |
Uzbek |
uz |
Vietnamese |
vi |
Welsh |
cy |
Xhosa |
xh |
Yiddish |
yi |
Yoruba |
yo |
Zulu |
zu |