3
votes

Maybe this is a hot question, but I had a strange issue (or more probably it's me :) ). I'm trying to use the new localization workflo in XCode 4.5. The procedure I'm using is the following:

  1. Create a project
  2. Localize MainStoryboard with the base language.
  3. Add new language.

So now I have three folders, for example:

  1. base.lproj
  2. en.lproj
  3. it.lprj

I have MainStoryboard.strings in en.lproj and it.lproj.

This is cool...

I noticed that .strings files are not auto filled while I'm modifying the layout (add, remove buttons, labels etc.).

I noticed that the .strings files are filled just when I localize the storyboard. To add new changes I need to remove localization and re-localize.

Doing so I loose my previous changes, i.e. I need to translate all the strings again.

What is wrong in my procedure?

I alos tried using a .sh in the Build Phases section, that auto-update .strings files, but the problem is the same, each time the files are update I loose my translations... (this sounds logic).

Thanks

2

2 Answers

3
votes

The trick is to convert your localized strings file to a localized storyboard file in the Localization area of the File Inspector.

Localization area of the File Inspector.

After that you can convert back to a strings file and you won't lose your translations.

0
votes

You can do this two ways. It sounds like you have created localized versions of your storyboard, which is fine, but you will have to un-check the localization box for Italian if you make changes to the Default (English) storyboard. Then re-check the Italian box to make the Italian storyboard pick up any changes that you made to the English storyboard.

or...

You can just use Localizable.strings files with a single storyboard, and programmatically handle all of the text using the NSLocalizedString(@"KEY",@"comment") method. After you create your initial Localizable.strings file, just localize it and add your Italian translations to the file in it.lproj.

Hopefully this makes sense. There are really two different localizations happening here. The first is allowing the system to choose the appropriate storyboard..that is typically used when you have translated text in the storyboard. The second is using the appropriate Localizable.strings file for the text values in you app.

Check out our app which can create 40+ Localization.strings files for you (including the translations). https://itunes.apple.com/app/generate-localizable-strings/id572287184?mt=12