My Cocoa project is localized in Italian (my language) and English language.
If I run it, i see everything in Italian (of course, my OS is italian!).
How can I run it to test the English localization without changing the OS language?

- 4,328
- 6
- 40
- 69
2 Answers
In the old times, Leopard and before, the get info window in Finder would let you choose the available languages. So it was a matter of deselecting the language that you don't want to use and it would "default" to the other.
These days you can use an utility like this one. I'd love to know what it does behind the scenes though.
I finally found a nice solution in the cocoa-dev mailing list archives.
Apparently, you can change the default domain within the arguments passed to
your executable, and this causes the global preference to be overwritten. It
can be achieved with the -AppleLanguages
flag, pass a list of the languages
in the preferred order:
~/apath/AppName.app/Contents/MacOS/AppName -AppleLanguages "(Italian, English)"
Run this from your terminal and it should give a different precedence for the
language. Notice you can also specify a single element list "(Italian)"
—makes more sense for testing purposes.
To do it within Xcode and avoid the terminal, go to the menu Product > Edit
Scheme… . Then, in your run configuration switch to the Arguments tab and
create a new one to be passed on launch. Add -AppleLanguages "(Japanese)"
text to it. Something similar to this:

- 57,726
- 14
- 108
- 151
-
@sidyll this is a nice solution. I'm going to try it on iOS when I get a chance - it would save the same hassle of changing the device language all the time. – Jessedc Dec 22 '11 at 00:06
-
even better! :D thank you very much (and we discovered how languageswitcher works ;D) – Oneiros Dec 22 '11 at 00:09
-
@Oneiros glad to help! And yeah, this is probably the trick behind it. – sidyll Dec 22 '11 at 00:15
-
Thanks @Jessedc . Once you test it, let me know about the results in iOS. I didn't find any to documentation regarding this "feature". I'll keep looking. – sidyll Dec 22 '11 at 00:16
-
Thanks @Jessedc , nice to know. I'll let you know when I find where is this documented :-) – sidyll Dec 22 '11 at 19:14
-
Thank you, such a brilliant solution! – Eddie Deng Jul 24 '16 at 12:58
Assuming you have a file that holds all the strings, swap the names of the files. Or, if you've got a it.lproj and en.lproj group in your project, just move your InfoPlist.strings (or whatever you named it) into the other group and vice versa.

- 8,902
- 2
- 36
- 44
-
thanks, useful trick. hadn't thought about it :D any other suggestions? – Oneiros Dec 21 '11 at 21:00
-
Yup, just edited my response with a little more info. In my case, I use a special file name, but you may be using localized groups with the same file name, in which case you just place the en.lproj string file into the it.lproj group for example. Of course, you will want to move them back before you deploy :D – Jeremy Dec 21 '11 at 21:05
-
Then you might consider changing it programmatically for debug purposes. I found this question that may be helpful for you: [change locale programmatically](http://stackoverflow.com/questions/3022628/change-locale-programmatically) – Jeremy Dec 21 '11 at 21:08