I'm trying to localize my first app, before I set about doing them localized all as I rewrite them in Swift. I must be doing some setting wrong, as everything looks right, but when run in the simulator the label texts do not change. I am coding on a MacBook Pro 2016, with macOS 10.12.3, using XCode 8.2.1 and targeting iOS 10.2 universal.
To clarify the situation, I made the simplest possible single view app, with one label named 'label1'. Base Internationalization is checked. I set the label text as follows in the view controller 'view did load':
label1.text = NSLocalizedString("label1Text", value: "Hello World", comment: "Main label")
Then I created .strings file Localizable.strings with this code:
"label1Text" = "Hello World";
Then in Project: Info, I added language French. XCode created Main.strings (French) with the following:
/ Class = "UILabel"; text = "Hello"; ObjectID = "ufk-lo-b4J"; */
"ufk-lo-b4J.text" = "Bonjour le monde"; (I inserted the French)
If I look at the storyboard in Assistant per Apple suggestions, and do 'preview', the text label is displayed in French.
I create a scheme 'testFrench' and set the options to 'French' , run (release), device to iPhone 7 plus, and run.
However, when the app runs in the simulator (or if loaded on my iPhone 7 plus set to French language), the text field displays in English. This is the same result I'm getting with my bigger app. Everything seems in place, but the text fields are not translated.
There must be a step or setting I am missing, but I cannot find anything to clarify this in the Apple docs, and there are no sample codes or tutorials I can find using XCode 8.2.1 and Swift 3.1 posted.