2 Replies
      Latest reply on Aug 5, 2015 1:42 AM by eskimo
      tlmk Level 1 Level 1 (0 points)

        Dear experts - Currently, I am trying to use localize feature on swift. Actually, i can change the display language when the iphone default langauge had been changed. However, I want to provide UI (like picture as follow link http://tinypic.com/r/fw3cyu/8) to let user to select the display language. How to do it? Please give me some hints. Thank you.

         

        Regards

         

        Tommy

        • Re: Localization on swift
          tlmk Level 1 Level 1 (0 points)

          Actually, I can reload the storyboard by using the other language resource as code below. However, the pictures and images cannot be located to correct path. The error is shown {Could not load the "second" image referenced from a nib in the bundle with identifier "(null)"}. Any idea to fix this problem. Thank you.

           

                  var reloadSB : UIStoryboard = UIStoryboard(name:"Main", bundle: NSBundle(path: NSBundle.mainBundle().pathForResource("zh-Hant", ofType: "lproj")!))
                  var reloadView : UIViewController =    reloadSB.instantiateInitialViewController() as! UIViewController
                  UIApplication.sharedApplication().keyWindow?.rootViewController=reloadView
          
          
          • Re: Localization on swift
            eskimo Apple Staff Apple Staff (11,265 points)

            I want to provide UI (like picture as follow link …) to let user to select the display language.

            The system does not support changing your app's localisation on the fly.  If you look through the App Frameworks / Localization topic area (which is where I moved your question, btw) you'll find that a significant fraction of the threads are from people having problems when they try to do this.  You may be able to work around some of the problems but there are others that have no workaround.  Probably the most significant relates to system UI components.

            If the system puts up a UI component on your behalf (the document picker, or Game Center user interface parts, or whatever) it will do so in the localisation that it thinks that your app is running in.  If your app is 'pretending' to run in some other language, you'll end up with a mixed localisation, where some parts of your app (the parts you control) are in one language and other parts of your app (the parts controlled by the OS) are in another.  That's a very poor user experience.

            In my opinion it is much better to avoid this problem entirely by localising your app in the standard way and relying on the system to choose the language for you based on the user's system-wide preferences.

            Share and Enjoy

            Quinn "The Eskimo!"
            Apple Developer Relations, Developer Technical Support, Core OS/Hardware
            let myEmail = "eskimo" + "1" + "@apple.com"