1
votes

So, in my project I have 10 languages, and 10 Localizable.strings files. I just created Localizable.strings files, a file for each language. Now they contain "key" = "value" pairs, and both keys and values are in English (default language).

My languages are all translated and stay in Excel files.

The question is, how can I insert all my languages in those files faster than just copying each word manually or writing a script for that? Maybe there is a existing tool for this already? Thanks.

4
Write a script to do it for you ;). If you copy an excel file into a normal text editor, it will give you a TSV file (tab separated value). As long as your strings don't contain any tabs it will be a piece of cake to parse with python or ruby or whatever you like.borrrden
I am going to learn python one day... :/Ankit Srivastava

4 Answers

9
votes

I found an easy way to compose localizable.strings files from Excel documents.

In the Excel document, in specific columns I insert " " = " " symbols. It's easy to do for all the words by dragging Excel cell down from the corner, so that it copies stuff from that cell to all the cells you drag it to. (sorry for messy explanation)

Thus the document contains the same symbols and words as localizable.strings does. Than I just copy everything to the text file, remove tabs, change extension to .strings. (no comments saved unfortunately).

EDIT: You can copy the stuff from Excel to Sublime Text, then Find & Replace tabs if any. Copy resulted stuff into proper Xcode .string file.

3
votes

One application that will really save you a lot of time by automating and streamlining localization procedure is Localization Suite. I do not know if they support importing from excel (to save you time transferring your string pairs) but it's free and seems like a complete solution.

3
votes

I had an internal script at work for doing that tasks in iOS and Android, and I've just opensourced it as a Gem. You can take a look at it here: http://github.com/mrmans0n/localio

It can open spreadsheets from Google Drive and local Excel files as well, like requested.

You just would have to install the gem

gem install localio

And have a custom DSL file in your project directory, called Locfile, with the info referring to your project and the localization files. An example in your case, where an Excel file is used, could be as simple as:

platform :ios
source :xls, :path => 'YourExcelFileGoesInHere.xls'
output_path 'Resources/Localizables/'

The .xls file should have a certain format, that probably is very similar to what you have right now. You just have to clone the contents of this one and fill it with your translations: https://docs.google.com/spreadsheet/ccc?key=0AmX_w4-5HkOgdFFoZ19iSUlRSERnQTJ4NVZiblo2UXc

Hope this helps.

1
votes

Here are the steps i followed:

  1. change the extension of .strings to .txt on windows
  2. open excel and go to File > Open
  3. Choose the file to open. This should present an import wizard
  4. Follow the steps and specify the delimiting character as =

You're done