Skip to content

Instantly share code, notes, and snippets.

@ppeszko
Created November 4, 2016 08:13
Show Gist options
  • Select an option

  • Save ppeszko/8ef41e1a88303ce6419c67784ff23324 to your computer and use it in GitHub Desktop.

Select an option

Save ppeszko/8ef41e1a88303ce6419c67784ff23324 to your computer and use it in GitHub Desktop.
Language switching without phone restart
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