最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin7PV0评论

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

Post a comment

comment list (0)

  1. No comments so far