1

I have an app that works with two languages arabic and english. I made to Localizable string files one for each , and it is working properly, when I change the system language the language of the app is changing, but I need to do that when the user presses a button to change the application language while still inside it.

0

1 Answer 1

1
var localized: String {
  let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate

        var lang = "en"

        if(appDelegate.isGreek)
        {
            lang = "el"
        }
        let path = NSBundle.mainBundle().pathForResource(lang, ofType: "lproj")
        let bundle = NSBundle(path: path!)

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

Where el is for greek language and this is extension to String class.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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