-1

I have recently started using localized Strings in my app and today I found this weird issue. For the time being, I support in my app two languages: English (the language of the project) and Italian (my native language). Today I tried changing my language to English and my app crashed with this error "Fatal Error Unexpectedly found nil while unwrapping an Optional value"; now, I know this is an optional-related error but I do not understand what does it mean in this situation. Here's the code from the viewDidLoad method:

photosLabel.text = NSLocalizedString("photosLabelText", comment: "The text of the label under the photo's counter")

And here there's the line from the Localizable.strings (English)

"photosLabelText" = "Photos";

P.S. Looking around in my project I found that in the storyboard under the voice "Localization" English and Italian voice are different; here's the screenshot

enter image description here

1 Answers1

0

If photosLabel is an IBOutlet, make sure that you link to it from the (English) storyboard not the (Base).

Note: Change the name of your file Localizable.string to Localizable.strings, it's just a typo.

ielyamani
  • 17,807
  • 10
  • 55
  • 90
  • Sorry, my fault...I made a typo, yes, but inside this question, not in my project – Lorenzo Santini Aug 30 '18 at 22:37
  • Btw I have one more question. What are the differences between the Base main Storyboard and the English one? – Lorenzo Santini Aug 30 '18 at 23:03
  • Glad I could help – ielyamani Aug 30 '18 at 23:03
  • @LorenzoSantini The Base is the one used by the app by default, the other languages might be chosen by the user in the Settings. [This](https://developer.apple.com/library/archive/documentation/MacOSX/Conceptual/BPInternational/InternationalizingYourUserInterface/InternationalizingYourUserInterface.html#//apple_ref/doc/uid/10000171i-CH3-SW2) is how base internalization is defined in the docs. – ielyamani Aug 30 '18 at 23:12