Skip to content

Localised Strings in addition to currentLocaleΒ #219

@uny

Description

@uny

I would like to use localized strings in addition to NSLocale.currentLocale().

Pattern 1:

struct string {
  struct localizable {
    let locale: NSLocale
    init(locale: NSLocale = NSLocale.currentLocale()) {
      self.locale = locale
    }
    /// Locales: en, ja
    static func helloWorld() -> String {
        return String(format: NSLocalizedString("HelloWorld", comment: ""), locale: self.locale)
    }
  }
}

Pattern 2:

struct string {
  struct en {
    /// Locales: en, ja
    static func helloWorld() -> String {
        return String(format: NSLocalizedString("HelloWorld", comment: ""), locale: NSLocale(localeIdentifier: "en"))
    }
  }
}

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions