سؤال

I use several storyboards and I have just decided to localize them (.strings files have been generated by Xcode).

I notice that in the Build Phases > Copy Bundle Resources, all resources related to localization appear in red.

Xcode screenshot

At run time, localization works only on the main storyboard. Localization with Localizable.strings also works. But it doesn't on the other storyboards.

I tried to restart Xcode but it didn't change anything. (cf Base internationalization and multiple storyboard not working right)

My localized storyboards were previously compiled. I f I add another storyboard, localize it and lauch the compilation, it fails with this error:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'Maintenance' in bundle NSBundle (...)

Do you have any idea to solve this issue?

هل كانت مفيدة؟

المحلول

This error is probably due to the fact that you didn't implement one of more languages you chose to localize in your application settings.

In order to implement a language in a storyboard :

  1. Select the storyboard
  2. On the right panel, go to the File inspector tab (first from the left)
  3. In Localization, check all language(s)

You now have two ways to localize your storyboard :

  • Either you choose to create a .strings file for your language by choosing Localizable Strings, this will generate a list of strings xcode found in your storyboard.
  • Or you can choose to create a "sub"-storyboard by choosing Interface Builder Cocoa Touch Storyboard which creates a different version of your storyboard for a particular language.

So far I only found one way to refresh the .strings file in xcode if you add new strings : simply uncheck and recheck the language and select "Replace File" when asked. Apple also provides a tool you can use in the terminal. Finally there's a script that does it automatically.

نصائح أخرى

  • Open the storyboard file
  • See the right panel, on first tab (identity) on the localization section, uncheck "Base"
  • You should be prompted a dialog, no matter the answer the problem should be fixed.

Now you see that the Build Phases is correct, and you should be able to run your project.

One of the reasons for the red Localizable.strings or other Localization-files which can't be copied in the 'Copy Bundle Resources' can be the setting for the 'Localization native development region' in your Target settings.

This region should be added to the 'Localizations' of your project.

I.e. if the 'Localization native development region' is 'en', then 'English' should be added as Localization in your project settings.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top