Search code examples
iosxcodelocalizable.strings

XCode - iOS localization not taken into account


I have looked around at various answers here but can't figure out what's going on.

My iPhone is in French. I have just one target. I went on the project settings and said "Add Localization" and added French.

I made sure to

  • clean/rebuild my app several times
  • check that build log shows up the files copy
  • remove app from my phone
  • run both on phone (8.1) and on the simulator with French
  • check that checkboxes are ticked on target/project settings

End result : Storyboard is localized but programmable strings are not (the NSLocalizedString("xxx", nil) shows xxx instead of yyy)

Any idea ? Here are some screenshots of my configuration

build log project files fr/localized.strings file settings

Thanks


Solution

  • Found the reason you're having this problem here:

    Note: Localizable.strings is the default filename iOS uses for localized text. Resist the urge to name the file something else, otherwise you will have to type the name of your .strings file every time you reference a localized string.

    If you want to use a different .strings file for localization, you need to use the method:

    - (NSString *)localizedStringForKey:(NSString *)key
                                  value:(NSString *)value
                                  table:(NSString *)tableName
    

    and specify Localized.strings as the third (tableName) parameter.