No localization from Main.Storyboard (English)

The problem I am facing is that all texts, titles, labels to be translated automatically in the Storyboard are not. At the same time, all texts, labels, titles to be translated by my Swift code, using NSLocalizableStrings are working well.


Here is my environment :

Xcode v 9.4.1

Development Language : English


Localization, English - 6 files localized

Development Language : French - 2 files localized (this line is below the other, correct ?)


Main.Storyboard includes:

  • Main.Storyboard (Base)
  • Main.strings (English), which contains all translations in English

The .strings files are correct and contains the translations for NSLocalizable functions


I have done Export for Localization to get an en.xliff file

In the file, it says source=fr and target=en, which is good

I have translated labels, titles, texts, etc.

I have done Import for Localization with the en.xliff file


To test localization, I do Edit Scheme / Run with Application Language set to English and Application Region set to System Region


What I see :

Whatever the view, all texts to be translated by a NSLocalizableString function in the Swift code are correctly translated and displayed as expected. Good

But, all texts to be translated automatically by the Storyboard are still displayed in French. All of them (View Title, Button, Label, etc). It looks like the Main.strings (English) is not read at all.


This last part is supposed to be straight forward, isn’t it ?


I have redo the full Localization process, with no effect.


My backup solution is to move all translations into the Swift code and not take advantage of the Storyboard automated translations, but honestly this is not exciting.


Any clue ? Any help ?

Many thanks

Accepted Reply

Hi Claude31. By the time you answered, I had already launched a DTS ticket. And your answer was correct. Apple recommended me to copy the full project to another folder, in Finder. Just copy paste the folder and its content. I did and it worked immediately Unbelievable. All my environment, code, storyboard was correct except probably a tiny bug somewhere. I now run my app from this new folder and get all translations. They said they don't know why, but at least it solves the issue. Another thing I learned is that code overwrites storyboard translations. Meaning if you do a "outlet".setTitle for instance, that will overwrite any translation coming first from the storyboard. Thanks Claude31

Replies

Test it by changing the iPhone language in the simulator :

- Settings

- General

- language & region

- select iPhon Language English.


Does it work ?

I am running the app on a Mac Book Pro. In XCode, there is a Simulator which I use. But in the Simulator menus, there is no Settings choice.

Are you talking about this Simulator ?

It is not a menu in the simulator, but the "iphone" settings.


1. Leave your app

2. Open the Settings Apps on the simulator screen

3. Change there the language

4. Relaunch your app

I have tested multiple times, rotating the language between French, English and System Language. I have also revert to English Devt language and FR as localization and redo the full Export, Import process. No change. The NSLocalizableStrings work but never the Storyboard translations. The only benefit with this configuration is to have the line "English Development Language" to be the first, and French below, which makes more sense. I also checked the Info.plist. The Localization native development region must be set to a country where english is the language (to be consistent with the above) : United States, England. Otherwise the NSLocalizable fucntions failed to find the .strings file. So I am stuck at the same point. No Storyboard translations.

In the file navigator, you should see the following :

> Main.storyboard

Main Storyboard (Base)

Main Storyboard (English)

Main Storyboard (French)


Do you get them ?


When you select Main storyboard, go to the Inspector File inspector.


Do you see in Localization pane:

- Base

- English

- Frenck

with the checkbox selected

that's interesting. As of the current configuration (with English as Devt lang and French as Localization)

In the file navigator, I see the following :

> Main.storyboard

Main Storyboard (Base)

Main Storyboard (French)

I don't have the (English) line


And for Main storyboard, Inspector File shows in Localization pane:

- Base checked

- English unchecked Localized Strings

- French checked Localized Strings

Try and check english.


And then reexport XLiff

No effect on Storyboard translations. I did another test by removing the Main.Storyboard (localiz) file. The Linker failed, good news, this file is required. But apparently it's not read at Run. Strange enough.

It is surprising you don't have the english main.strings.


I would try the following :

- create a duplmicate of your complete project folder in Finder (avoid working on the original file!)

- In the directory, you should see the list of all folders, such as :

Base.lproj

Controllers

en.lproj

es.lproj

fr.lproj

Info.plist

Models

Nib et Storyboards

Base.lproj

en.lproj

es.lproj

fr.lproj

Outils

Resources

Settings.bundle


If it is missing, duplicate fr.lproj and name it en.lproj

It containes 2 files if you have a launch screen:

LaunchScreen.strings

Main.strings


Then, edit manually the file to translate texts:

/* Class = "UIButton"; normalTitle = "Prendre une photo"; ObjectID = "3Ao-rp-veT"; */

"3Ao-rp-veT.normalTitle" = "Prendre une photo";


Change tyhe lmast line into

"3Ao-rp-veT.normalTitle" = "Shoot a photo";


Then check the en.lproj appears in the file browser in XCode and run app.

Hi Claude31. By the time you answered, I had already launched a DTS ticket. And your answer was correct. Apple recommended me to copy the full project to another folder, in Finder. Just copy paste the folder and its content. I did and it worked immediately Unbelievable. All my environment, code, storyboard was correct except probably a tiny bug somewhere. I now run my app from this new folder and get all translations. They said they don't know why, but at least it solves the issue. Another thing I learned is that code overwrites storyboard translations. Meaning if you do a "outlet".setTitle for instance, that will overwrite any translation coming first from the storyboard. Thanks Claude31

Great. I have had some issues with localization as well.


In particular, UITextView are not localized (in XCode 9).


See here if you have the problem:

h ttps://stackoverflow.com/questions/28596877/localization-of-ios-storyboard-uitextview-texts-are-not-localized

h ttps://stackoverflow.com/questions/19426421/uitextview-localized-with-xib-strings-file


Don't forget to mark the thread as closed with the correct answer.

Good to read the solution I proposed you was the correct answer.