Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode: Run project with specified localization


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?

like image 690
Oneiros Avatar asked Dec 21 '11 20:12

Oneiros


People also ask

How do I add localization files to Xcode?

Right click your project folder, select 'New File' , then scroll down to find 'Strings', select it and click 'Next'. Then name the file as 'Localizable. strings' and click 'Create'.

How do you perform localization in iOS Swift?

Click on iOS->App/Single View App->Next. Name your project and select the language as Swift. Select a desired location and click on Create. To start with Localization, click on your Project Name -> go to Info Tab -> Under Localizations, click on the '+' button.

How do I use localized strings in Swiftui?

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 dynamic localization?

Dynamic localization is the suppression of the broadening of a charged-particle wave packet as it moves along a periodic potential in an a.c. electric field1,2,3.


1 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:

Xcode Screen Shot

like image 96
sidyll Avatar answered Sep 19 '22 18:09

sidyll