Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode 5/iOS 7 - localization not working in simulator

I was following one of Ray Wenderlich's tutorials on localization but I can't seem to get it working.

I've set my project up for localization in English and French and I have a locaziable.strings file for each:

enter image description here

The French file has the correct (well as far as Google translate goes) French versions of my string:

enter image description here

I'm setting the strings by calling the correct key from the localizable.strings file:

 NSString* strTitle = [NSString stringWithFormat:NSLocalizedString(@"Title", Nil)]; 

And I have the simulator set to French (BTW: Whenever I do a language change the simulator crashes).

But it is not pulling from the correct localizable.strings file. It's still displaying in English:

enter image description here

Am I doing something wrong?

like image 278
PruitIgoe Avatar asked Sep 27 '13 19:09

PruitIgoe


People also ask

How do I use localization in Xcode?

Open Info tab, and click “+” button under Localizations section. Then choose a language you want to support from the dropdown list shown. XCode opens a dialog showing resources to be added for the new language.

How do I select simulated device as destination in Xcode?

Click view-->show toolbar if you don't see it. Click on IOS Device and you should get a drop down menu of devices. The simulator should be in that list.

How do I enable simulator in Xcode?

Open Xcode and click Menu > Xcode > Preferences > Select Components, and then choose the simulator version you want to download.

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.


2 Answers

If you are using xcode 6.1.1 and iOS sdk 8.1,try this workaround.

It seems localization does not work with xCode 6.1 and 8.1 simulator. Workaround: Go to "edit schemes" >> "Run" (side bar) >> "Options" tab >> "Application Language" Select the language you wish to run the app on the simulator. I got this workaround from Workaround by natanavra Thanks to him.

However I read on developer forum,that it is working in 6.2 beta version of Xcode. Hope it do.

like image 167
Rajal Avatar answered Oct 03 '22 20:10

Rajal


Maybe you have run the app at some time where the file Localizable.strings already existed but has not been localized yet. If this is the case, this unlocalized file still resides in the resources folder in the application bundle in the simulator (when you build an run a new version of your app in the simulator or in the device, unused files will not be deleted). This can lead to problems.

Try to delete the app completely from the simulator and build an run again.

like image 36
Theo Avatar answered Oct 03 '22 19:10

Theo