TiagoLinharess
TiagoLinharess

Reputation: 1

Could not Localize strings in my xcframework

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: https://github.com/TiagoLinharess/app-ios-financial-control-v2

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

Upvotes: 0

Views: 37

Answers (0)

Related Questions