Skip to content

Instantly share code, notes, and snippets.

@ayanonagon
Created October 19, 2014 20:31
Show Gist options
  • Save ayanonagon/9f653365c9a920ff0a89 to your computer and use it in GitHub Desktop.
Save ayanonagon/9f653365c9a920ff0a89 to your computer and use it in GitHub Desktop.
Changing the locale in a Swift playground
import UIKit
extension NSLocale {
class func currentLocale() -> NSLocale {
return NSLocale.localeWithLocaleIdentifier("en_GB");
}
}
NSLocale.currentLocale().localeIdentifier
let numberFormatter = NSNumberFormatter()
numberFormatter.numberStyle = NSNumberFormatterStyle.CurrencyStyle
numberFormatter.stringFromNumber(10)
@xaphod
Copy link

xaphod commented Apr 15, 2018

Swift 4 version:

extension Locale {
    static var current : Locale { return Locale.init(identifier: "fr_FR") }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment