Localization on swift

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

Replies

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

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"

While responding to another thread I came across this ‘money quote’ from WWDC 2019 Session 403 Creating Great Localized Experiences with Xcode 11:

First, do not attempt to set the application language manually in code.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"