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.
1 Answer
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.