Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force genstrings to build the Localizable.strings file in order of appearance rather than alphabetically

I'm new to internationalization and localization for iOS. I'm running genstrings: find . -name \*.m | xargs genstrings -o en.lproj to generate my Localizable.strings files. It builds the file in alphabetical order (by key).

For ease of translation I'd prefer that the keys and values be ordered by their order of appearance in the .m files. Is this possible with genstrings? I couldn't find the relevant info on its man page.

like image 1000
MattyG Avatar asked Jul 17 '12 16:07

MattyG


People also ask

How do you make a string file localizable?

Let us move on to create a string file called 'Localizable' that will hold the text we want to localize. Choose File → New → File …, select Strings File under Resources, and click Next. Name it Localizable, then click on Create.

What is localizable string?

Localizable. strings stores application strings as key-value pairs for each language. Let's create this file for the base language first. Select File → New → File… or just tap Ctrl+N or Cmd+N .


2 Answers

You could do something like:

find . -name '*.m' -print | xargs -n1 genstrings -a

I'm sure there are more elegant ways. Perhaps just use ls *.m instead of the find. The strings are kept together by file with -a switch but they are still sorted within each file.

like image 111
Mel Pullen Avatar answered Oct 04 '22 13:10

Mel Pullen


It is not possible to change the behavior of genstrings other than what it is allowed within the parameters specified in the manual:

https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man1/genstrings.1.html

but if you want to ease the translation you can use Linguan

http://www.cocoanetics.com/apps/linguan/

If you want to stick to genstrings and are having some trouble with it you can try this page, it offers a good explanation:

http://spritebandits.wordpress.com/2012/01/25/ios-iphone-app-localization-genstrings-tips/

But yeah returning to the main question, it is not possible in my knowledge.

like image 25
Pochi Avatar answered Oct 04 '22 14:10

Pochi