TXLocaleState

public final class TXLocaleState : NSObject

Keeps track of the locale-related information for the application, such as supported locales, source and current locale.

  • The locale of the source language

    Declaration

    Swift

    @objc
    public private(set) var sourceLocale: String { get }
  • The currently selected locale that is being displayed in the app

    Declaration

    Swift

    @objc
    public var currentLocale: String { get }
  • A list of all locales supported in the app, including the source locale.

    Declaration

    Swift

    @objc
    public private(set) var appLocales: [String] { get }
  • An array containing the app’s locales without the source locale.

    Declaration

    Swift

    @objc
    public private(set) var translatedLocales: [String] { get }
  • Constructor.

    Declaration

    Swift

    @objc
    public init(sourceLocale: String? = nil,
         appLocales: [String] = [],
         currentLocaleProvider: TXCurrentLocaleProvider? = nil
    )

    Parameters

    sourceLocale

    the locale of the source language, defaults to “en” if no source locale is provided

    appLocales

    a list of all locales supported by the application, defaults to the source locale if the appLocales list is empty. If the source locale is not included in this list, it’s added during initialization.

    currentLocaleProvider

    an object conforming to CurrentLocaleProvider protocol, defaults to TXPreferredLocaleProvider

  • Returns true if the given locale is the source locale, false otherwise.

    Declaration

    Swift

    public func isSource(_ locale: String) -> Bool

    Parameters

    locale

    the locale to check against

    Return Value

    true if the given locale is the source locale, false otherwise

  • Returns true if the given locale is the currently selected locale, false otherwise.

    Declaration

    Swift

    public func isCurrent(_ locale: String) -> Bool

    Parameters

    locale

    the locale to check against

    Return Value

    true if the given locale is the currently selected locale, false otherwise

  • Returns true if the given locale is defined in the app configuration, false otherwise.

    Declaration

    Swift

    public func isAvailableInApp(_ locale: String) -> Bool

    Parameters

    locale

    the locale to check against

    Return Value

    true if the given locale is defined in the app configuration, false otherwise

  • Description of the source string used for debugging purposes

    Declaration

    Swift

    public override var debugDescription: String { get }