Localizer

public enum Localizer

Properties

  • Array of (String, String) tuples containing the code and name of the application’s supported languages

    Declaration

    Swift

    public static var languageOptions: [(code: String, name: String)] { get }
  • Current default language of the application

    Declaration

    Swift

    public static var defaultLanguage: String { get }
  • Current language of the application

    Declaration

    Swift

    public static var currentLanguage: String { get }

Methods

  • Fetches the localized version of the string in a specific bundle

    Declaration

    Swift

    public static func getLocalizedVersion(ofString string: String, in bundle: Bundle) -> String

    Parameters

    string

    Key of the string that will be fetched

    bundle

    Bundle where the string will be fetched

    Return Value

    The localized version of the string

  • Fetches the localized version of the string in all necessary bundles

    Declaration

    Swift

    public static func stringFor(key: String) -> String

    Parameters

    string

    Key of the string that will be fetched

    Return Value

    The localized version of the string

  • Gets the language name of a specific language using its code

    Declaration

    Swift

    public static func getDisplayNameForLanguage(_ language: String) -> String

    Parameters

    language

    Language code (“en”, “it”, etc.)

  • Sets the language of the application using its code and stores it in UserDefaults, then broadcasts a notification that the language has been changed

    Declaration

    Swift

    public static func setCurrentLanguage(_ language: String)

    Parameters

    language

    Language code (“en”, “it”, etc.)

  • Resets the language of the application to default

    Declaration

    Swift

    public static func resetCurrentLanguageToDefault()