1

The problem my IOS app is facing is that all texts, titles, labels to be translated automatically in the Storyboard are not. At the same time, all texts, titles, labels 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 in the en .xliff file
  • I have done Import for Localization using 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 removed three times English and 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

Ashley Mills
  • 50,474
  • 16
  • 129
  • 160
OCA92
  • 11
  • 6

1 Answers1

0

Problem: If you create Localization StoryBoard. and after that you will add some label or button then That will not available in Localization storyboard.

Solution: Delete complete Localization Story(< YourStoryBoardName >.String) from project. Don't remove only refrence.

Open en.lproj> < YourStoryBoardName >.String And Delete. Do this for other language also This Then again create this you will find all button and label in Localization

Important Note:

By deleting your All localization String will delete So do the backup first.

Anup Gupta
  • 1,993
  • 2
  • 25
  • 40
  • Thanks Anup. Few more comments about your answer. I didn't add new texts, labels, etc. This is happening right at the first time. Will your answer still apply ? It looks your text has been corrupted, is there a sentence between "This Then again" ? – OCA92 Jun 23 '18 at 08:46
  • Check Your **Id** for **textfield** and **Label** In they are available in localization String or not if not available then automatic it will not create. Then you need to create **Localizable.strings** file in your project. – Anup Gupta Jun 23 '18 at 19:36
  • The IDs are present and correct for all textfields and labels. – OCA92 Jun 24 '18 at 07:00
  • delete the String file and create new this is the only solution. – Anup Gupta Jun 24 '18 at 07:05
  • I have deleted the Main.strings (English) from the en.lproj. Import again the en.xliff with the translations. New Main.strings (English) is back to same place. Build and run, same effect, no translation. – OCA92 Jun 24 '18 at 10:36
  • https://stackoverflow.com/questions/48240039/swift-localization-in-storyboard-labels-not-added-to-main-strings?rq=1 see this – Anup Gupta Jun 24 '18 at 17:04
  • 2
    Finally, I got an answer from Apple DTS. Copy the project (the main folder) to a new folder, and have Xcode to open that folder. That will "refresh" Xcode. And yes I did it and yes it worked ! All my translations from the Storyboard came. Unbelievable. Thanks to Anup Gupta who tried to provide me some help. – OCA92 Jul 02 '18 at 06:31
  • @OCA92 i am currently facing the same issue and your solution here is not working out for me, can u please help? – Mohsin Khubaib Ahmed Jan 15 '19 at 09:55
  • Well, the only thing Apple told me was to copy my project with a new name and restart Xcode with that file. Nothing really fancy but it worked. That's all I can say, sorry – OCA92 Jan 16 '19 at 10:26