Class: NSLocale
Overview
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.
Class Method Summary (collapse)
-
+ autoupdatingCurrentLocale
Returns the current logical locale for the current user.
-
+ availableLocaleIdentifiers
Returns an array of NSString objects, each of which identifies a locale available on the system.
-
+ canonicalLanguageIdentifierFromString:
Returns a canonical language identifier by mapping an arbitrary locale identification string to the canonical identifier.
-
+ canonicalLocaleIdentifierFromString:
Returns the canonical identifier for a given locale identification string.
-
+ characterDirectionForLanguage:
Returns the character direction for the specified ISO language code.
-
+ commonISOCurrencyCodes
Returns an array of common ISO currency codes Common codes may include, for example, AED, AUD, BZD, DKK, EUR, GBP, JPY, KES, MXN, OMR, STD, USD, XCD, and ZWD.
-
+ componentsFromLocaleIdentifier:
Returns a dictionary that is the result of parsing a locale ID.
-
+ currentLocale
Returns the logical locale for the current user.
-
+ ISOCountryCodes
Returns an array of NSString objects that represents all known legal country codes.
-
+ ISOCurrencyCodes
Returns an array of NSString objects that represents all known legal ISO currency codes.
-
+ ISOLanguageCodes
Returns an array of NSString objects that represents all known legal ISO language codes.
-
+ lineDirectionForLanguage:
Returns the line direction for the specified ISO language code.
-
+ localeIdentifierFromComponents:
Returns a locale identifier from the components specified in a given dictionary.
-
+ localeIdentifierFromWindowsLocaleCode:
Returns a locale identifier from a Windows locale code.
-
+ preferredLanguages
Returns the user's language preference order as an array of strings.
-
+ systemLocale
Returns the “root”, canonical locale, that contains fixed “backstop” settings that provide values for otherwise undefined keys.
-
+ windowsLocaleCodeFromLocaleIdentifier:
Returns a Window locale code from the locale identifier.
Instance Method Summary (collapse)
-
- displayNameForKey:value:
Returns the display name for the given value.
-
- initWithLocaleIdentifier:
Initializes the receiver using a given locale identifier.
-
- localeIdentifier
Returns the identifier for the receiver.
-
- objectForKey:
Returns the object corresponding to the specified key.
Methods inherited from NSObject
#!, #!=, #!~, #, #==, #===, #=~, #Rational, #__callee__, #__method__, #__send__, #__type__, `, alloc, allocWithZone:, #autoContentAccessingProxy, autoload, autoload?, autorelease_pool, #awakeAfterUsingCoder:, binding, block_given?, caller, cancelPreviousPerformRequestsWithTarget:, cancelPreviousPerformRequestsWithTarget:selector:object:, catch, class, classFallbacksForKeyedArchiver, #classForCoder, #classForKeyedArchiver, classForKeyedUnarchiver, #clone, conformsToProtocol:, #copy, copyWithZone:, #dealloc, #define_singleton_method, description, display, #doesNotRecognizeSelector:, #dup, #enum_for, #eql?, #equal?, #extend, fail, #finalize, format, #forwardInvocation:, #forwardingTargetForSelector:, framework, #freeze, #frozen?, getpass, gets, global_variables, #init, initialize, #initialize_clone, #initialize_copy, #initialize_dup, #inspect, instanceMethodForSelector:, instanceMethodSignatureForSelector:, #instance_eval, #instance_exec, #instance_of?, #instance_variable_defined?, #instance_variable_get, #instance_variable_set, #instance_variables, instancesRespondToSelector:, isSubclassOfClass:, #is_a?, iterator?, #kind_of?, lambda, load, load_bridge_support_file, load_plist, local_variables, loop, #method, #methodForSelector:, #methodSignatureForSelector:, #methods, #mutableCopy, mutableCopyWithZone:, new, #nil?, open, p, #performSelector:onThread:withObject:waitUntilDone:, #performSelector:onThread:withObject:waitUntilDone:modes:, #performSelector:withObject:afterDelay:, #performSelector:withObject:afterDelay:inModes:, #performSelectorInBackground:withObject:, #performSelectorOnMainThread:withObject:waitUntilDone:, #performSelectorOnMainThread:withObject:waitUntilDone:modes:, print, printf, #private_methods, proc, #protected_methods, #public_method, #public_methods, #public_send, putc, puts, raise, rand, readline, readlines, #replacementObjectForCoder:, #replacementObjectForKeyedArchiver:, require, resolveClassMethod:, resolveInstanceMethod:, #respond_to?, #respond_to_missing?, select, #send, setVersion:, #singleton_methods, sprintf, srand, superclass, #taint, #tainted?, #tap, test, throw, #to_plist, #to_s, trace_var, trap, #trust, #untaint, untrace_var, #untrust, #untrusted?, version
Constructor Details
This class inherits a constructor from NSObject
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class NSObject
Class Method Details
+ (Object) autoupdatingCurrentLocale
Returns the current logical locale for the current user. Settings you get from this locale do change as the user’s settings change (contrast with currentLocale).Note that if you cache values based on the locale or related information, those caches will of course not be automatically updated by the updating of the locale object. You can recompute caches upon receipt of the notification (NSCurrentLocaleDidChangeNotification) that gets sent out for locale changes (see Notification Programming Topics to learn how to register for and receive notifications).
+ (Array) availableLocaleIdentifiers
Returns an array of NSString objects, each of which identifies a locale available on the system.
+ (String) canonicalLanguageIdentifierFromString(string)
Returns a canonical language identifier by mapping an arbitrary locale identification string to the canonical identifier.
+ (String) canonicalLocaleIdentifierFromString(string)
Returns the canonical identifier for a given locale identification string.
+ (NSLocaleLanguageDirection) characterDirectionForLanguage(isoLangCode)
Returns the character direction for the specified ISO language code.
+ (Array) commonISOCurrencyCodes
Returns an array of common ISO currency codes Common codes may include, for example, AED, AUD, BZD, DKK, EUR, GBP, JPY, KES, MXN, OMR, STD, USD, XCD, and ZWD.
+ (Hash) componentsFromLocaleIdentifier(string)
Returns a dictionary that is the result of parsing a locale ID. For example: the locale ID "en_US@calendar=japanese" yields a dictionary with three entries: NSLocaleLanguageCode=en, NSLocaleCountryCode=US, and NSLocaleCalendar=NSJapaneseCalendar.
+ (Object) currentLocale
Returns the logical locale for the current user. Settings you get from this locale do not change as a user’s Preferences are changed so that your operations are consistent. Typically you perform some operations on the returned object and then allow it to be disposed of. Moreover, since the returned object may be cached, you do not need to hold on to it indefinitely. Contrast with autoupdatingCurrentLocale.
+ (Array) ISOCountryCodes
Returns an array of NSString objects that represents all known legal country codes. Note that many of country codes do not have any supporting locale data in OS X.
+ (Array) ISOCurrencyCodes
Returns an array of NSString objects that represents all known legal ISO currency codes. Note that some of the currency codes may not have any supporting locale data in OS X.
+ (Array) ISOLanguageCodes
Returns an array of NSString objects that represents all known legal ISO language codes. Note that many of the language codes do not have any supporting locale data in OS X.
+ (NSLocaleLanguageDirection) lineDirectionForLanguage(isoLangCode)
Returns the line direction for the specified ISO language code.
+ (String) localeIdentifierFromComponents(dict)
Returns a locale identifier from the components specified in a given dictionary. This reverses the actions of componentsFromLocaleIdentifier:, so for example the dictionary NSLocaleCountryCode="US", NSLocaleCalendar=NSJapaneseCalendar becomes "en_US@calendar=japanese".
+ (String) localeIdentifierFromWindowsLocaleCode(lcid)
Returns a locale identifier from a Windows locale code.
+ (Array) preferredLanguages
Returns the user's language preference order as an array of strings.
+ (Object) systemLocale
Returns the “root”, canonical locale, that contains fixed “backstop” settings that provide values for otherwise undefined keys.
+ (Integer) windowsLocaleCodeFromLocaleIdentifier(localeIdentifier)
Returns a Window locale code from the locale identifier.
Instance Method Details
- (String) displayNameForKey(key, value:value)
Returns the display name for the given value. Not all locale property keys have values with display name values.You can use the NSLocaleIdentifier key to get the name of a locale in the language of another locale, as illustrated in the following examples. The first uses the fr_FR locale.returnsThe following example uses the en_GB locale.returns
- (Object) initWithLocaleIdentifier(string)
Initializes the receiver using a given locale identifier.
- (String) localeIdentifier
Returns the identifier for the receiver. Equivalent to sending objectForKey: with key NSLocaleIdentifier.
- (Object) objectForKey(key)
Returns the object corresponding to the specified key.