nicklockwood / CountryPicker

CountryPicker is a custom UIPickerView subclass that provides an iOS control allowing a user to select a country from a list. It can optionally display a flag next to each country name, and the library includes a set of 249 high-quality, public domain flag images from FAMFAMFAM (http://www.famfamfam.com/lab/icons/flags/) that have been painstakingly re-named by country code to work with the library.
http://charcoaldesign.co.uk/source/cocoa#countrypicker
Other
740 stars 153 forks source link

Request: Don't localized country name #18

Open ghost opened 9 years ago

ghost commented 9 years ago

I need the country name to always be in English. (Disregard localization and i18n) (Localized country name is a great feature but I would like to have an option to define single permanent language). Is it possible with current code? Can you make it available? Great picker - Thanks!

Omarj commented 9 years ago

@MatanGold I was going to ask for the same thing but when i read the documentation , I found that it is already implemented:

@property (nonatomic, copy) NSLocale *selectedLocale;

This is a convenience property to set/get the selected country using a locale. The picker will automatically select the correct country based on the local. To default the picker to the current device locale, you can say:

picker.selectedLocale = [NSLocale currentLocale];

Omarj commented 9 years ago

@MatanGold or u can go to + (NSDictionary *)countryNamesByCode;

and edit the code inside the for loop to be like this :+1:

NSString *countryName

        //workaround for simulator bug
       // if (!countryName)
      //  {
            countryName = [[NSLocale localeWithLocaleIdentifier:@"en_US"] displayNameForKey:NSLocaleCountryCode value:code];
      //  }

        namesByCode[code] = countryName ?: code;