I’ve a SwiftUI framework that is i wish to implement Localizable Strings for English and Brazilian Portuguese, right here is my venture, code and github repo:
My HomeLocalizable.swift:
enum HomeLocalizable {
// MARK: - House -
enum House {
static let title = HomeLocalizable.tr("Localizable", "residence.title", fallback: "Monetary Management")
}
}
// MARK: - Implementation Particulars -
extension HomeLocalizable {
non-public static func tr(_ desk: String, _ key: String, _ args: CVarArg..., fallback worth: String = "") -> String {
let format = BundleToken.bundle.localizedString(forKey: key, worth: worth, desk: desk)
return String(format: format, locale: Locale.present, arguments: args)
}
}
non-public remaining class BundleToken {
static let bundle: Bundle = {
#if SWIFT_PACKAGE
return Bundle.module
#else
return Bundle(for: BundleToken.self)
#endif
}()
}
String recordsdata:
String file 1
String file 2
Github venture: https://github.com/TiagoLinharess/app-ios-financial-control-v2
I attempted utilizing Localizable in Textual content()
view, the instance above, and i could not get the translated worth, solely the keys or fallback