Localization on the fly with localized Storyboards

后端 未结 2 1956
遇见更好的自我
遇见更好的自我 2021-02-09 21:06

I\'m working on an app that has a toggle button to switch between English and Arabic language and should be on the fly. I\'m using the method in https://github.com/maximbilan/io

2条回答
  •  眼角桃花
    2021-02-09 21:26

    change the bundle which is used to init the storyboard:

            let path = Bundle.main.path(forResource: "ar", ofType: "lproj")
            let bundle = Bundle(path: path!)
            let delegate : AppDelegate = UIApplication.shared.delegate as! AppDelegate
            let storyboard = UIStoryboard(name: "Main", bundle: bundle)
            delegate.window?.rootViewController = (storyboard.instantiateInitialViewController())
    

    although this change the storyboard based on language but do not load images! :(

提交回复
热议问题