Locales encapsulate information about linguistic, cultural, and technological conventions and standards. Examples of information encapsulated by a locale include the symbol used for the decimal separator in numbers and the way dates are formatted. Locales are typically used to provide, format, and interpret information about and according to the user’s customs and preferences. They are frequently used in conjunction with formatters.
Questions tagged [nslocale]
257 questions
455
votes
33 answers
Getting current device language in iOS?
I'd like to show the current language that the device UI is using. What code would I use?
I want this as an NSString in fully spelled out format. (Not @"en_US")
EDIT: For those driving on by, there are a ton of useful comments here, as the answer…

Moshe
- 57,511
- 78
- 272
- 425
201
votes
18 answers
How to get current language code with Swift?
I want get the language code of the device (en, es...) in my app written with Swift. How can get this?
I'm trying this:
var preferredLanguages : NSLocale!
let pre = preferredLanguages.displayNameForKey(NSLocaleIdentifier, value:…

user3739367
- 4,161
- 6
- 20
- 18
59
votes
7 answers
How to get country code using NSLocale in Swift 3
Could you please help on how to get country code using NSLocale in Swift 3 ?
This is the previous code I have been using.
NSLocale.currentLocale().objectForKey(NSLocaleCountryCode) as! String
I can get Language Code as below in Swift…

digidhamu
- 717
- 1
- 6
- 12
36
votes
13 answers
How do I get a list of countries in Swift ios?
I've already seen two similar questions to mine, but the answers for those questions do not work for me. I have an old project with a list of countries manually typed out inside a set of square brackets.
I can easily use this in my pickerView but…

LondonGuy
- 10,778
- 11
- 79
- 151
24
votes
2 answers
NSLocale preferredLanguages objectAtIndex:0 always return "en"
Simulator's language already changed to Japanese, why [[NSLocale preferredLanguages] objectAtIndex:0] always return "en"?
Neither preferred language nor region is related to "en", where does "en" come from?
Tried to get [[NSLocale…

S1U
- 825
- 2
- 14
- 26
24
votes
9 answers
Get country code from country name in IOS
Im retrieving a country name from a server in english. For example, "Spain"
What I want to do is, assuming the country name is going to be written in english, get the country code.
What should I do? I´ve found getting the country name from the…

pdrcabrod
- 1,467
- 1
- 14
- 22
19
votes
5 answers
Check language in iOS app
Task is : I have got two UIImageViews, and I want present ImageView1 if system language is Ukrainian, and if it is not Ukrainian(English/Polish etc) I want present ImageView2.
I tried :…

Pavel Zagorskyy
- 443
- 1
- 4
- 20
17
votes
5 answers
xcode 6.1 iOS 8.1 NSLocale displayNameForKey NSLocaleIdentifier return nil
- (NSString *)countryNameByCode:(NSString*)countryCode
{
NSString *identifier = [NSLocale localeIdentifierFromComponents:@{NSLocaleCountryCode: countryCode}];
NSString *countryName = [[NSLocale currentLocale]…

Yuriy Bosov
- 211
- 2
- 5
15
votes
6 answers
How do I get current application locale?
I need to get current locale. Not user locale but my application locale.
Let's say my application has two localizations (in project settings): English (default) and French. If user sets French language on iPhone then my application will display…

Alexander
- 959
- 5
- 11
- 29
14
votes
5 answers
NSLocale Swift 3
How do I get the currency symbol in Swift 3?
public class Currency: NSObject {
public let name: String
public let code: String
public var symbol: String {
return NSLocale.currentLocale().displayNameForKey(NSLocaleCurrencySymbol,…

I make my mark
- 841
- 6
- 13
14
votes
2 answers
NSLocaleCountryCode returns nil
I have a bugreport that states a crash in the following line, where client is an instance of NSMutableDictionary
[client setObject:[[NSLocale currentLocale] objectForKey:NSLocaleCountryCode] forKey:@"country"];
My guess is, that NSLocaleCountryCode…

Michael Ochs
- 2,846
- 3
- 27
- 33
14
votes
6 answers
NSLocale currency symbol, show before or after amount value
I am using StoreKit to implement an in app purchase store in my application.
I have a custom design and it means that the value of the price should be white and large, and the currency symbol smaller, darker and aligned to the top of the price…

Daniel
- 23,129
- 12
- 109
- 154
13
votes
1 answer
Know when to use short or full month names
Under iOS 7 or 8, the stock Calendar app does something that I have been unable to figure out.
Under some locales, such as en_US, the Calendar app shows the short (3-letter) month names.
Under other locales, such as de_DE, the Calendar app shows the…

rmaddy
- 314,917
- 42
- 532
- 579
12
votes
6 answers
NSDateformatter setDateFormat according to currentLocale
I'm going mad with, probably, a stupid problem.
I have 3 strings: year, month and day. I need to have a date in the right format based on currentLocale, so i.e. if currentLocale localeIdentifier is en_US my dateFormat should be:
MMM/dd/yyyy
if it's…

masgar
- 1,875
- 2
- 20
- 32
12
votes
2 answers
What's the difference between NSLocale currentLocale vs autoupdatingCurrentLocale?
What's the difference between NSLocale currentLocale vs autoupdatingCurrentLocale? It's not obvious from reading the documentation.

Boon
- 40,656
- 60
- 209
- 315