Swiftpack.co - LeaderBoy/Localizable as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by LeaderBoy.
LeaderBoy/Localizable 1.1.0
Localized string scheme
⭐️ 0
🕓 1 year ago
iOS
.package(url: "https://github.com/LeaderBoy/Localizable.git", from: "1.1.0")

Localizable

Code From

How to get the localized string?

just

.food.local /// Food or 食物

Example

enum Tag : String {
    case traffic
    case food
    case cosmetics
}

extension Tag : Localizable {
    var key: String {
        return "tag_" + self.rawValue
    }

    var value: String {
        return self.rawValue
    }
}

in Localizable.strings you need the following:

English Version

"tag_traffic" = "Traffic";
"tag_food" = "Food";
"tag_cosmetics" = "Cosmetics";

Chinese Version

"tag_traffic" = "交通";
"tag_food" = "餐饮";
"tag_cosmetics" = "化妆品";

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics