Created
November 4, 2016 08:13
-
-
Save ppeszko/8ef41e1a88303ce6419c67784ff23324 to your computer and use it in GitHub Desktop.
Language switching without phone restart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let resourceName: String | |
| switch userLanguage { | |
| case .German: | |
| resourceName = "Base" | |
| case .French: | |
| resourceName = "fr" | |
| case .Unknown: | |
| resourceName = nameFromPhoneDefaults() | |
| } | |
| let path = Bundle.main.path(forResource: resourceName, ofType: "lproj") | |
| let bundle = Bundle(path: path!) | |
| let format = NSLocalizedString(key, tableName: nil, bundle: bundle!, value: "", comment: "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment