6 Replies
      Latest reply on Dec 21, 2019 10:49 AM by keegho
      mojo_10 Level 1 Level 1 (0 points)

        Hey everyone,


        I have a quick question, which I can't solve.


        I have a Tab Bar Controller from which you have access to a Table View controller. From this Table View Controller you can get to another View Controller.

        And in this you can change the language of my App.


        And lets say the user has set it to german and now wants to set it to english, the tab bar item titles should immediately change from the german words to the englisch ones. My Problem is that I haven't found a way to have access to the tab bar items titles from this View Controller. My only solution was updating it in every Tab Bar View Controller seperately, but then the update doesn't happen until the user clicks every Tab Bar Item ones.


        Hope somebody has a solution for me.

        • Re: Change Tab Bar Item Titles
          KMT Level 9 Level 9 (15,505 points)

          Does your localization work if the user quits the app first, then changes language on their device?

          • Re: Change Tab Bar Item Titles
            keegho Level 1 Level 1 (0 points)

            Hello dear...to be able to change the tab bar langauges you need to create a new coca touch custom class file that inherits from the UITabBarController class and assign this custom class name to the tabbar view controller in the story board then add this code to it according the number of tabs you have in the bar.

            Here im using Localize_Swift library from git hub and using its Localized class to change the tabbar titles using their keys that are found in the Localizable.strings files


            Plus i have added an observer also to detect the language changes happening so the tabbar custom class executues the functions i created for changing the languages as soon as the app discovers that the app locale has been changed.


            override func viewWillAppear(_ animated: Bool) {
                    NotificationCenter.default.addObserver(self, selector: #selector(setText), name: NSNotification.Name( LCLLanguageChangeNotification), object: nil)
                @objc func setText() {
                    tabBar.items?[0].title = Localized("Tab name 1").uppercased()
                    tabBar.items?[1].title = Localized("Tab name 2").uppercased()
                    tabBar.items?[2].title = Localized("Tab name 3").uppercased()
                    tabBar.items?[3].title = Localized("Tab name 4").uppercased()
                override func viewWillDisappear(_ animated: Bool) {