README.md in xcmultilingual-0.1.6 vs README.md in xcmultilingual-0.1.7

- old
+ new

@@ -57,44 +57,53 @@ ```swift import Foundation struct Multilingual { - enum Localizable: String { - case HELLO = "HELLO" - case GOODMORNING = "GOODMORNING" - case GOODEVENING = "GOODEVENING" + enum Animal: String { + case CAT = "CAT" + case DOG = "DOG" + case BEAR = "BEAR" + case DEER = "DEER" + case SQUIRREL = "SQUIRREL" + case ELEPHANT = "ELEPHANT" + case GIRAFFE = "GIRAFFE" + case TIGER = "TIGER" + case LION = "LION" + case RABBIT = "RABBIT" + case RHINOCEROS = "RHINOCEROS" + case GORILLA = "GORILLA" + case MONKEY = "MONKEY" func string() -> String { - return NSLocalizedString(rawValue, tableName: "Localizable", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "") + return NSLocalizedString(rawValue, tableName: "Animal", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "") } static func keys() -> [String] { - return ["HELLO", "GOODMORNING", "GOODEVENING"] + return ["CAT", "DOG", "BEAR", "DEER", "SQUIRREL", "ELEPHANT", "GIRAFFE", "TIGER", "LION", "RABBIT", "RHINOCEROS", "GORILLA", "MONKEY"] } static func localizations() -> [String] { - return Localizable.keys().map { Localizable(rawValue: $0)!.string() } + return Animal.keys().map { Animal(rawValue: $0)!.string() } } } - enum Animal: String { - case CAT = "CAT" - case DOG = "DOG" - case BEAR = "BEAR" - case DEER = "DEER" + enum Localizable: String { + case HELLO = "HELLO" + case GOODMORNING = "GOODMORNING" + case GOODEVENING = "GOODEVENING" func string() -> String { - return NSLocalizedString(rawValue, tableName: "Animal", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "") + return NSLocalizedString(rawValue, tableName: "Localizable", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "") } static func keys() -> [String] { - return ["CAT", "DOG", "BEAR", "DEER"] + return ["HELLO", "GOODMORNING", "GOODEVENING"] } static func localizations() -> [String] { - return Animal.keys().map { Animal(rawValue: $0)!.string() } + return Localizable.keys().map { Localizable(rawValue: $0)!.string() } } } private static func bundle(relativePath: String) -> NSBundle { var components = (__FILE__ as String).pathComponents @@ -148,12 +157,12 @@ If you want to use `LOC` for top level struct name. `xcmultilingual update ./DemoApp/Multilingual.swift -n LOC` and then you can write like `LOC.Animal.DOG.string()` ## Swift functions -`Multilingual` is swift struct. Localization files tables are represented as enum in this struct. +`Multilingual` is swift struct. Localization tables are represented as enum in this struct. -Each struct has `Table name` and `string()` instance function and `keys()` and `localizations()` static functions. +Each enum has `Table name` and `string()` instance function and `keys()` and `localizations()` static functions. Example: When you want to use Animal table's DOG key localization.