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?
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...!