2

App localization not working for the storyboard, meanwhile it's working with localizable.strings file for programmatically created elements. I checked it by changing the app language also, still no change with a storyboard.

This is how I am trying to switch between languages

func setSelectedLanguage(lang: String){
    guard let langPath = Bundle.main.path(forResource: lang, ofType: "lproj") else {
        appbundle = Bundle.main
        return
    }
    appbundle = Bundle(path: langPath)!
}

func getLocalizeString(key: String) -> String {
    return appbundle.localizedString(forKey: key, value: "", table: nil)

}

This is my storyboard with strings file

Storyboard

PS: I tried reinstalling the application, cleaning the project and deleting derived data. Thanks in advance.

1
  • Try changing strings file to interface storyboard in file inspector Dec 4, 2019 at 8:40

2 Answers 2

0

You should be able to localize directly from storyboard itself by entering the storyboard and selecting the checkboxes in localization area of first section of right panel, "Identity and Type". You can also choose whether you want to use localizable.strings for those elements which have unique identifiers or you can create localized copies of those storyboards, then change the content.

localization area in right panel

how it looks in localizable.string file

You can also benefit from this useful tutorial: localization in storyboard tutorial

0

When we localize the app from the storyboard sometime we make mistakes like not putting the semicolon in the string files. So you should check the generated string file carefully. Also, you can enable Show non-localized string from the edit scheme section in Xcode. Bu which you can get some error in the log of your Xcode. Then you can track which localize strings are missing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.