How to quickly localize storyboard on the fly?

狂风中的少年 提交于 2020-01-02 01:07:13

问题


I am trying to localize my app using Swift 3 and Xcode 8.1.

I am trying to localze the app using both storyboard(main.strings(German)) and programatically using "NSLocalizedString".

I am able to localize programatically using "NSLocalizedString" using following code

func localized(lang:String) ->String {

        let path = Bundle.main.path(forResource: lang, ofType: "lproj")
        let bundle = Bundle(path: path!)

        return NSLocalizedString(self, tableName:  nil, bundle: bundle!, value: "", comment: "")
    }

But I am stuck with the localizations which are defined in storyboard. I have defined localised string in main.strings(German).

/* Class = “IBUILabel”; text = “Date :”; ObjectID = “0sh-CK-26C”; */
“0sh-CK-26C.text” = “Datum :”;

Is there any way to localize the storyboard on run time?


回答1:


I think, the best way to localize a Storyboard is- You should first finish the design work in local language and then localize your storyboard in the desired language. Then export .xliff file and replace all the texts in the desired language. And then again import the .xliff file to your project. And you are done...!



来源:https://stackoverflow.com/questions/41186802/how-to-quickly-localize-storyboard-on-the-fly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!