Mc.Lover Mc.Lover - 1 year ago 118
Swift Question

Run iOS application only in English language and localization

I have built a calendar application. I need to force this application to run only in English language. Because if I change iPhone localization to Japanese app doesn't work properly, for example months and days of week are Japanese !

I need to force it to run only in English language, because everything is custom so right now I need to only focus on English language. I searched here and found this code to force application run in English localziation but it doesn't work ! :

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

let langCultureCode: String = "en"
let defaults = NSUserDefaults.standardUserDefaults()
defaults.setObject([langCultureCode], forKey: "AppleLanguages")

return true


Still when I run the app language is Japanese.Any help would be great !

I am showing dates with
, the common classes to show a date

func alternativeDate(indexPath:NSIndexPath) -> String {

let todayDate = NSDate()
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "MMMM d, y"

let calculatedDate = NSCalendar.currentCalendar().dateByAddingUnit(NSCalendarUnit.Day, value: indexPath.row, toDate: todayDate, options: NSCalendarOptions.init(rawValue: 0))
let calculatedDayString = dateFormatter.stringFromDate(calculatedDate!)

return calculatedDayString

Answer Source

You are the one who is asking for the date string to be translated into the current locale, by using NSDateFormatter. If you don't want that to happen, then make an English locale (using the identifier "en_US") and set the date formatter's locale to that.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download