DEV Community

Roger Molas
Roger Molas

Posted on • Edited on

iOS and Android Localization Tool

Localization is simply the process of translating your app into multiple languages.

In situation like you need support multiple language, including API response messages and dynamic strings you need a list of localizable .strings file, and you need to localized it based on the Language you want ( e.g English, Chinese, Japanese ).

Xcode has a built-in localizable file generator that generate your localizable .strings for each language you supported.

In this format

en.lproj  // directory
   |- localizable.strings

zh.lproj  // directory
   |- localizable.strings

ja.lproj  // directory
   |- localizable.strings
Enter fullscreen mode Exit fullscreen mode

Thats Cool!!

But how about the contents?

You need to copy and paste it base on it corresponding laguage. For Chinese stings you put it on zh.lproj/ localizable.strings and for Japanese stings put it on ja.lproj/ localizable.strings and your good to go.

Holy Shiiit, i have 400 stings that needs to be localized in 3 or more languages 400 x 3 = 1,200

Just copy and paste your 1,200 lines of string, Good Luck!

To solve the pain of copy and pasting and save time.

you can use the tool called csv-localizer GitHub stars available on Github.

Just instruct you translator or someone working on translations to put all translated strings into CSV file based on the format provided.

csv-localizer can be installed from homebrew via

$ brew tap rogermolas/csv-localizer
$ brew install csv-localizer
Enter fullscreen mode Exit fullscreen mode

Convert using the following command

$ csv-localizer -p ios -i path/csv_files/ -o path/output
Enter fullscreen mode Exit fullscreen mode

Input directory, CSV files directory path, should not include the .csv file
"path/csv_files/" and not "path/csv_files/strings.csv"

The reason for that is, csv-localizer can process multiple csv files, thats why its only accept a directory path.

Generated files

en.lproj  // directory
   |- localizable.strings

zh.lproj  // directory
   |- localizable.strings

ja.lproj  // directory
   |- localizable.strings
Enter fullscreen mode Exit fullscreen mode

Thats it, your ready to go. Easy Right?

It will generate the same format just like what Xcode did, but this time it has its localized contents in each corresponding laguage. :)

Also worked on Android it will generate string.xml with contents

$ csv-localizer -p android -i path/csv_files/ -o path/output
Enter fullscreen mode Exit fullscreen mode

Don't forget give a GitHub stars

Top comments (1)

Collapse
 
fkirc profile image
Felix K

I created the new tool "attranslate" to solve this problem: github.com/fkirc/attranslate Although this is intended for semi-automated translations, it can be also used just for the sake of synchronizing file structures.