nslocale Questions

8

Solved

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...
Trash asked 20/9, 2016 at 14:2

13

Solved

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 bra...
Katerine asked 10/1, 2015 at 11:0

18

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.displayName...
Fanti asked 5/7, 2014 at 22:45

33

Solved

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, th...
Domiciliary asked 11/10, 2010 at 21:58

9

Solved

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...
Can asked 1/10, 2012 at 10:48

5

Solved

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 : println(...
Him asked 22/3, 2015 at 10:30

2

I'm developing app that supports "en" and "ru" languages, users can select language inside app. If default phone's locale set to "en", but inside app selected "ru" language, then when trying to lo...
Lackadaisical asked 15/1, 2015 at 20:39

6

Solved

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 lan...
Latonia asked 1/5, 2015 at 12:39

5

Solved

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().disp...
Alboran asked 15/9, 2016 at 19:42

2

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 s...
Girdle asked 29/7, 2013 at 16:15

3

Solved

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 langua...
Falcongentle asked 22/9, 2015 at 11:9

4

Solved

I have this code: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; NSMutableArray *daysNames = [NSMutableArray arrayWithArray:dateFormatter.weekdaySymbols]; NSLog(@"daysNames = %@"...
Loginov asked 4/12, 2014 at 3:18

2

Solved

I have UIDatePicker in CountdownTimer mode and need to change the wording of hours and min to German locale. I tried both, to set locale to German (Germany) in storyboard and in code, but both fail...
Assent asked 2/1, 2018 at 15:42

1

Solved

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(@"R...
Worl asked 6/12, 2017 at 14:39

6

Solved

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 smal...
Lanlana asked 3/9, 2012 at 20:20

4

My app changes the language at runtime and advises the user to restart the app. I do it like this: typealias LanguageLocaleType = (language: String?, locale: String?, title: String) let element...
Nosing asked 30/6, 2017 at 21:36

2

Solved

Simulator's language already changed to Japanese, why [[NSLocale preferredLanguages] objectAtIndex:0] always return "en"? Neither preferred language nor region is related to "en&quot...
Privett asked 26/10, 2014 at 10:42

6

Solved

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 i...
Abiosis asked 9/5, 2011 at 15:4

2

Solved

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 ob...
Anastigmatic asked 14/11, 2011 at 18:6

4

I am trying this: NSDictionary *components = [NSDictionary dictionaryWithObject:@"USD" forKey:NSLocaleCurrencyCode]; NSString *localeIdentifier = [NSLocale localeIdentifierFromComponents:component...
Evslin asked 2/8, 2011 at 7:52

3

Solved

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 objectF...
Wini asked 24/8, 2011 at 0:28

2

Solved

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] forKe...
Tegucigalpa asked 4/3, 2013 at 13:15

1

Solved

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 *...
Overtop asked 27/7, 2015 at 10:43

3

Solved

How can I get an array with all countries names in Swift? I've tried to convert the code I had in Objective-C, which was this: if (!pickerCountriesIsShown) { NSMutableArray *countries = [NSMutabl...
Beirut asked 19/6, 2014 at 20:31

5

- (NSString *)countryNameByCode:(NSString*)countryCode { NSString *identifier = [NSLocale localeIdentifierFromComponents:@{NSLocaleCountryCode: countryCode}]; NSString *countryName = [[NSLocale ...
Corum asked 28/10, 2014 at 16:4

© 2022 - 2024 — McMap. All rights reserved.