Skip to content

Instantly share code, notes, and snippets.

@sirshannon
sirshannon / LocalisedStrings.swift
Created March 2, 2018 19:23 — forked from douglashill/LocalisedStrings.swift
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)
}