NSLocale.preferredLanguages doesn't change when changing NSUserDefaults

i have been researching this for days now.

i have a swift ready application , lately we decided to introduce localization, when i set the system language to the desired language , it works , but when i try to manually change the language it doesn't work.

what i have tried :

    NSUserDefaults.standardUserDefaults().setObject(["ar"], forKey: "AppleLanguage")
    NSUserDefaults.standardUserDefaults().synchronize()

after i restart the app

let lang = NSUserDefaults.standardUserDefaults().objectForKey("AppleLanguage") does return ["ar"]

but

NSLocale.preferredLanguages()[0]

still returns ["en"]

and the application appears in the english version and locale

Upvotes: 1

Views: 1159

Answers (1)

Clafou
Clafou

Reputation: 15410

The key is named AppleLanguages (note the s at the end).

I'm sure you know, but localized apps don't need to perform custom language selection. It's best to leave it to iOS which lets users define their global international settings.

Upvotes: 1

Related Questions