1. <strong id="7actg"></strong>
    2. <table id="7actg"></table>

    3. <address id="7actg"></address>
      <address id="7actg"></address>
      1. <object id="7actg"><tt id="7actg"></tt></object>

        xcmultilingualSwift 本地化的命令行工具

        聯(lián)合創(chuàng)作 · 2023-09-27 15:19

        xcmultilingual 是用于 Swift 本地化的命令行工具。它分析項(xiàng)目中的本地化文件,和輸出包含有補(bǔ)充的函數(shù)的轉(zhuǎn)移文件。

        代碼示例:

        import Foundation
        struct Multilingual {
            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: "Animal", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "")
                }
                static func keys() -> [String] {
                    return ["CAT", "DOG", "BEAR", "DEER", "SQUIRREL", "ELEPHANT", "GIRAFFE", "TIGER", "LION", "RABBIT", "RHINOCEROS", "GORILLA", "MONKEY"]
                }
                static func localizations() -> [String] {
                    return Animal.keys().map { Animal(rawValue: $0)!.string() }
                }
            }
            enum Localizable: String {
                case HELLO = "HELLO"
                case GOODMORNING = "GOODMORNING"
                case GOODEVENING = "GOODEVENING"
                func string() -> String {
                    return NSLocalizedString(rawValue, tableName: "Localizable", bundle: NSBundle.mainBundle(), value: "\(rawValue)", comment: "")
                }
                static func keys() -> [String] {
                    return ["HELLO", "GOODMORNING", "GOODEVENING"]
                }
                static func localizations() -> [String] {
                    return Localizable.keys().map { Localizable(rawValue: $0)!.string() }
                }
            }
            private static func bundle(relativePath: String) -> NSBundle {
                var components = (__FILE__ as String).pathComponents
                components.removeLast()
                let bundlePath = join("/", components) + "/" + relativePath
                return NSBundle(path: bundlePath) ?? NSBundle.mainBundle()
            }
        }
        瀏覽 21
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        評論
        圖片
        表情
        推薦
        點(diǎn)贊
        評論
        收藏
        分享

        手機(jī)掃一掃分享

        編輯 分享
        舉報(bào)
        1. <strong id="7actg"></strong>
        2. <table id="7actg"></table>

        3. <address id="7actg"></address>
          <address id="7actg"></address>
          1. <object id="7actg"><tt id="7actg"></tt></object>
            成人网在线视频 | 中文字幕在线伦理 | se久久久婷婷 | 一级全黄少妇性色生活片免费 | 久久国产激情视频 | 精品无码一区二区三区免费 | 淫荡熟女网 | 青青草A片| 男人操女人逼逼 | 性生活片免费看 |