Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to quickly localize storyboard on the fly?

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?

like image 928
New iOS Dev Avatar asked Dec 16 '16 14:12

New iOS Dev


1 Answers

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

like image 150
Krishna Datt Shukla Avatar answered Oct 29 '22 00:10

Krishna Datt Shukla