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
0
votes
1 answer
dateFromString returned a wrong date after setLocale
I have following codes:
NSDate *today = [NSDate date];
NSDateFormatter *formatter = [[NSDateFormatter alloc]init];
NSLocale *zh_CN = [[NSLocale alloc]initWithLocaleIdentifier:@"zh_CN"];
[formatter setLocale:zh_CN];
[formatter…

Daniel Chen
- 1,933
- 5
- 24
- 33
0
votes
1 answer
Getting Use of Undeclared Identifier error with imported method
I'm trying to use the userVisibleDateTimeStringForRFC3339DateTimeString method that Apple documents here.
So first I created a separate class called jhsDateFormatter and first modified it from
- (NSString…

Jazzmine
- 1,837
- 8
- 36
- 54
0
votes
1 answer
Why does Apple use NSString objects as parameters instead of enums?
For example, why use this:
NSLocale *l = [[NSLocale alloc] initWithLocaleIdentifier@"en_US"];
Instead of something like this:
NSLocale *l = [[NSLocale alloc] initWithLocaleIdentifier:NSLocaleIdentifierUS];
It seems like it would prevent a lot of…

pasawaya
- 11,515
- 7
- 53
- 92
0
votes
1 answer
NSLocale - invalid identifiers
If I am trying to initialize a NSLocale with a certain locale identifier, how can I tell if it is a legit identifier? No matter what identifier I pass in, even a garbage one, NSLocale still gets initialized to something.
For example, if you pass in…

baselq
- 301
- 6
- 17
0
votes
1 answer
Display date in chinese in iphone
How to display current date in Chinese. I receive date in English language but I need to display it in Chinese in iphone.

iPhone Developer
- 459
- 1
- 5
- 14
0
votes
2 answers
NSLocale - finding CountryCode and then using this to deploy code
I am stumped as to why this code isn't working as per the comment below:
NSString *countryCode = [[NSLocale currentLocale] objectForKey: NSLocaleCountryCode];
NSLog(@"Country Code: %@", countryCode);
if (countryCode == @"US") {
NSLog(@"Country…

Ben T
- 141
- 1
- 10
0
votes
2 answers
Localizing iPhone app for Region
I've got an app that has all content regardless of language displaying content in English. In the products section of the app product content is displayed based on a plist. Products available for purchased are based on location, not all products…

propstm
- 3,461
- 5
- 28
- 41
0
votes
1 answer
Difference between – displayNameForKey:value: and - objectForKey: in NSLocale Class
Hi just a quick question what is the difference between – displayNameForKey:value: and - objectForKey: in NSLocale Class? I searched online but didn't get it. Thank you.
Apple Document
displayNameForKey:value:
Returns the display name for the given…

ThinkChris
- 1,169
- 2
- 15
- 38
0
votes
1 answer
Windows LOCALE_SABBREVLANGNAME on Mac OS X
Our application needs to talk to a server component, which (stupidly) takes a Windows language abbreviation (SABBREVLANGNAME) as a parameter. On Mac OS X you can get LCID pretty easily from an NSLocale, but there's no way that I can tell to get the…

Ryan
- 11
- 2
0
votes
1 answer
Localization by Location or Region?
How can I make the localization independent on the OS settings?
For example, if the device language is en-US,
But I want the user to be able to set the app to work using Hebrew localization.
In my case – I have an app that in emergency cases the…

Maor Zohar
- 592
- 5
- 17
-1
votes
1 answer
iOS Simulator Device Language doe not match Settings
My understanding is that the device language should be set via: Settings > General > Language & Region. My device shows "English" as the language, however when I open my app, certain text such as the Apple sign-in method, and the "back" button for…

ChicagoBen83
- 1
- 2
-1
votes
1 answer
Locale.currentlocale not getting expected result?
As i know Locale.currentLocale returns locale details in setting like language and region in mobile settings
But in my case I have selected English language and region United States
Still current locale returns region code
"CN", expected one is…

Vinod Jadhav
- 1,055
- 1
- 15
- 37
-1
votes
2 answers
How to reduce the amount of currency codes you get back from NSLocale.Key.currencyCode
I have an ios app that I'm trying to allow the users to select which currency they want to use. Right now I have the full list of currencies but there seem to be some duplicates there such as:
Is there a way to filter out the others? The dollar…

icekomo
- 9,328
- 7
- 31
- 59
-1
votes
2 answers
NSDateFormater stringFromDate to dateFromString return wrong date
My code:
NSString *dateStr = @"03-02-2017";//[responseObject objectForKey:@"event_date"];
NSLog(@"'%@'", dateStr);
// Convert string to date object
NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
NSLocale *locale =…

KTang
- 340
- 1
- 17
-1
votes
1 answer
Is there a way to get the current NSLocaleCountryCode of the user?
I am currently getting the NSLocaleCountryCode by
NSLocale *currentLocale = [NSLocale currentLocale]; NSString *countryCode = [currentLocale objectForKey:NSLocaleCountryCode]; Now, the problem is if the iPhone or iPad is bought from a certain…

drbj
- 113
- 9