Questions tagged [nslocale]

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.

257 questions
12
votes
3 answers

Run unittests with a specific locale (en_US or none)

Is there a way to force a specific locale when running unittests? Eg. always use en_US or force no locale, so that none of the .lproj files are loaded. My unittest is sensitive to the currently selected language in the Settings app (in the iOS…
neoneye
  • 50,398
  • 25
  • 166
  • 151
12
votes
2 answers

iOS - Determine User's country without using CLLocationManager

I don't need precise location data, and I don't want the user to see the "This App wants to determine your location" Alert. I just need to determine the user's country, assuming they have an internet connection via network or wi-fi. What is the best…
soleil
  • 12,133
  • 33
  • 112
  • 183
10
votes
4 answers

Does the weekdaySymbol list always start with Sunday in any country?

I have this code: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSMutableArray *daysNames = [NSMutableArray arrayWithArray:dateFormatter.weekdaySymbols]; NSLog(@"daysNames = %@", daysNames); it outputs: daysNames = ( Sunday, …
ppalancica
  • 4,236
  • 4
  • 27
  • 42
9
votes
2 answers

Can I get the code for the local currency from an NSLocale?

Can I get the code for the local currency from an NSLocale? I tried this: NSLocale *locale = [[[NSLocale alloc] initWithLocaleIdentifier:@"fr_FR"] autorelease]; NSString *currencyCode = [locale objectForKey:NSLocaleCurrencyCode]; but currencyCode…
Simon
  • 25,468
  • 44
  • 152
  • 266
9
votes
1 answer

Getting Locales on iOS 5

I have this piece of code that gets a few information (current country, country name) from NSLocale. It works without any problem in iOS 4.3 but crashes in iOS 5. Upon checking it seems that [locale localeIdentifier] and [locale displayNameForKey:…
user829227
  • 256
  • 2
  • 7
9
votes
3 answers

Localization: How to get the current user language?

I'm about to localize an iPhone application. I want to use a different URL when the user's language (iOS system language) is german. I want to know if this is the correct way of doing that: NSURL *url = [NSURL URLWithString:@"http://..."]; //…
Felix
  • 35,354
  • 13
  • 96
  • 143
8
votes
1 answer

NSLocale returning wrong value in iOS 11

Starting from iOS 11.0, the following code returns "de_US" instead of "en_US": // => Returns "de_US" NSString *regionCode = [[NSLocale currentLocale] objectForKey:NSLocaleIdentifier]; NSLog(@"Region code: %@", regionCode); Below iOS 11, it returns…
hico
  • 1,850
  • 1
  • 19
  • 28
8
votes
1 answer

NSLocale Country Code and Name is Null

I am using the below code for Code and Country name but it returns null. NSLocale *locale = [NSLocale currentLocale]; NSString *countryCode = [locale objectForKey: NSLocaleCountryCode]; NSString *country = [locale displayNameForKey:…
iYousafzai
  • 1,021
  • 1
  • 10
  • 29
8
votes
1 answer

How can I change the locale for my app programmatically via Swift?

I have a language selection control in my application, and I want to be able to set the locale accordingly during runtime. How can I achieve this?
daaniaal
  • 501
  • 7
  • 13
7
votes
1 answer

What locale argument to pass to NSDecimalNumber +decimalNumberWithString:locale: so it always works with NSString's using the dot (.) decimal mark?

I have an NSString which I want to convert into an NSDecimalNumber. The string is received from a server and is always formatted using the en_US locale like XXX.YYY and not like XXX,YYY. I want to create an NSDecimalNumber which accepts XXX.YYY…
Dave
  • 12,408
  • 12
  • 64
  • 67
7
votes
3 answers

List of Countries using NSLocaleCountryCode

I want to be able to make the app change depending on the users location. Im using the code below: NSLocale *locale = [NSLocale autoupdatingCurrentLocale]; NSString *countryCode = [locale objectForKey: NSLocaleCountryCode]; NSString…
daihovey
  • 3,485
  • 13
  • 66
  • 110
7
votes
4 answers

How to get NSLocale from currency code?

I am trying this: NSDictionary *components = [NSDictionary dictionaryWithObject:@"USD" forKey:NSLocaleCurrencyCode]; NSString *localeIdentifier = [NSLocale localeIdentifierFromComponents:components]; NSLocale *localeForDefaultCurrency = [[NSLocale…
kastet
  • 209
  • 1
  • 3
  • 6
7
votes
3 answers

Uppercase All String According to Locale - Swift

I'm trying to uppercase all string according to 'Locale' but it is not working. var text = "istanbul, izmir" println(text.uppercaseStringWithLocale(NSLocale.currentLocale())) In Turkish language the uppercase for i is İ not I. My Result is…
Luai Kalkatawi
  • 1,492
  • 5
  • 25
  • 51
7
votes
1 answer

NSLocale Language Issue

So in my app I am trying to get the devices currently set language and its acronym. So I do this: NSString *fullLanguage = [[NSLocale currentLocale] displayNameForKey:NSLocaleIdentifier value:[[NSLocale preferredLanguages]…
SimplyKiwi
  • 12,376
  • 22
  • 105
  • 191
7
votes
1 answer

Localizing Numbers in iOS

Simply, I have a positive integer [9, 393, 3, 993], and I would like to localize it to a certain language [٩, ٣٩٣ ,٣ ,٩٣٩]. If I use NSNumberFormatter, it will localize the number according to the user's locale. However, I want to override that and…
Mazyod
  • 22,319
  • 10
  • 92
  • 157
1
2
3
17 18