最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ios - Could not Localize strings in my xcframework - Stack Overflow

programmeradmin2浏览0评论

I have a SwiftUI framework that's i want to implement Localizable Strings for English and Brazilian Portuguese, here is my project, code and github repo:

My HomeLocalizable.swift:

enum HomeLocalizable {
    // MARK: - Home -
    enum Home {
        static let title = HomeLocalizable.tr("Localizable", "home.title", fallback: "Financial Control")
    }
}

// MARK: - Implementation Details -

extension HomeLocalizable {
  private static func tr(_ table: String, _ key: String, _ args: CVarArg..., fallback value: String = "") -> String {
    let format = BundleToken.bundle.localizedString(forKey: key, value: value, table: table)
    return String(format: format, locale: Locale.current, arguments: args)
  }
}

private final class BundleToken {
  static let bundle: Bundle = {
    #if SWIFT_PACKAGE
    return Bundle.module
    #else
    return Bundle(for: BundleToken.self)
    #endif
  }()
}

String files: String file 1 String file 2

Github project:

I tried using Localizable in Text() view, the example above, and i couldn't get the translated value, only the keys or fallback

发布评论

评论列表(0)

  1. 暂无评论