Skip to content

Instantly share code, notes, and snippets.

View MacMeDan's full-sized avatar

Dan Leonard MacMeDan

View GitHub Profile
@douglashill
douglashill / LocalisedStrings.swift
Last active September 17, 2018 09:02
Generating an enum to ensure only defined localised string keys are used. For development on Apple platforms.
// Douglas Hill, February 2018
import Foundation
/// Returns a localised string with the key as an enum case so the compiler checks it exists.
/// The enum should be automatically generated using UpdateLocalisedStringKeys.swift.
public func localisedString(_ key: LocalisedStringKey) -> String {
return Bundle.main.localizedString(forKey: key.rawValue, value: nil, table: nil)
}