SITMultilanguageString

Objective-C

@interface SITMultilanguageString : NSObject

Swift

class SITMultilanguageString : NSObject

A string with a different value depending of the language. ISO 639-2 is used to identify the languages.

See

ISO3Language

Initializers

  • This method initializes the object and sets the default locale for the localized string. Right now only english and spanish are supported. If a different locale is passed to this method, english will be set as default.

    Declaration

    Objective-C

    - (instancetype _Nonnull)initWithDefaultLocale:
        (NSLocale *_Nonnull)defaultLocale;

    Swift

    init(defaultLocale: Locale)

    Parameters

    defaultLocale

    A valid NSLocale object to be set as the default locale. (Only english and spanish supported as default)

    Return Value

    Initialized instance of SITMultilanguageString with the default locale set.

Methods

  • Obtain the value corresponding to the default locale.

    Declaration

    Objective-C

    - (NSString *_Nullable)value;

    Swift

    func value() -> String?

    Return Value

    An string containing the value of the string for the default locale.

  • Obtain the value corresponding to the selected locale.

    Declaration

    Objective-C

    - (NSString *_Nullable)valueForLocale:(NSLocale *_Nonnull)locale;

    Swift

    func value(for locale: Locale) -> String?

    Parameters

    locale

    A valid NSLocale object to be used to obtain the string value.

    Return Value

    An string containing the value of the string for the selected locale.

  • Get the locale set as default. (Only english and spanish supported as default)

    Declaration

    Objective-C

    - (NSLocale *_Nonnull)defaultLocale;

    Swift

    func defaultLocale() -> Locale

    Return Value

    A locale representing the default locale selected.

  • Get the locales contained in this object.

    Declaration

    Objective-C

    - (NSArray *_Nonnull)locales;

    Swift

    func locales() -> [Any]

    Return Value

    An array containing all avaliable locales for the string.

  • This method sets the default locale for the localized string. Right now only english and spanish are supported. If a different locale is passed to this method, english will be set as default.

    Declaration

    Objective-C

    - (void)setDefaultLocale:(NSLocale *_Nonnull)locale;

    Swift

    func setDefaultLocale(_ locale: Locale)

    Parameters

    locale

    A valid NSLocale object to be set as the default locale. (Only english and spanish supported as default)

  • This method sets a new value and locale for the localized string. Right now only english and spanish are supported. If a different locale is passed to this method, english will be set as default.

    Declaration

    Objective-C

    - (void)setValue:(NSString *_Nonnull)string
           forLocale:(NSLocale *_Nonnull)locale;

    Swift

    func setValue(_ string: String, for locale: Locale)

    Parameters

    string

    String with the value associated to the selected locale.

    locale

    A valid NSLocale object to be set with the associated string.

Deprecated

  • Deprecated

    This constructor is deprecated. Please use initWithDefaultLocale: and set the string values with setValue:withLocale:

    This method initializes the object and sets the default value and locale for the localized string. Right now only english and spanish are supported. If a different locale is passed to this method, english will be set as default.

    Declaration

    Objective-C

    - (instancetype _Nonnull)initWithValue:(NSString *_Nonnull)value
                             defaultLocale:(NSLocale *_Nonnull)defaultLocale;

    Swift

    init(value: String, defaultLocale: Locale)

    Parameters

    value

    String with the value associated to the selected default locale.

    defaultLocale

    A valid NSLocale object to be set as the default locale. (Only english and spanish supported as default)

    Return Value

    Initialized instance of SITMultilanguageString with the default locale set.