Areej Qadomi Areej Qadomi - 4 months ago 21x
iOS Question

changing app language using buttons in runtime

I'm trying to change the application language using two buttons, First I used this code in this link :
Localize.swift and placed it in my project ,
And here is the code of the table view controller that has two buttons and two lables :

import UIKit

class MyTableViewVontroller: UITableViewController {

@IBOutlet weak var firstLabel: UILabel!

@IBOutlet weak var secondLabel: UILabel!

@IBOutlet weak var arabicChanger: UIBarButtonItem!

@IBOutlet weak var englishChanger: UIBarButtonItem!

override func viewDidLoad() {




@IBAction func englishChanger(sender: AnyObject) {


@IBAction func arabicChanger(sender: AnyObject) {


override func didReceiveMemoryWarning() {


// Dispose of any resources that can be recreated.


func populateValues(){

firstLabel.text = NSLocalizedString("PETRA",comment: "")

secondLabel.text = NSLocalizedString("AMMAN",comment: "")


But when I run it and press any of the buttons nothing changes. Even though localization works just fine as I have a Strings files for both languages and when changing language from the system it works, but it doesn't when the buttons are pressed.


let me first quote what the library's github information page says

To update the UI in the viewcontroller where a language change can take place, observe LCLLanguageChangeNotification :

you have to add an observer for this to change, to know how an observer works,get your self familiar with NSNotificationCenter

by the way, I don't recommend to use a third party library in this case, just go with the standards for simple tasks, try using the default NSLocalizedString localization, it's great !