Add SPM badge
this swift package will make it easy to enable typed access to your literals specified in the Localizable.strings file.
Localizable.strings
swift run -c release TypedTranslations Localizable.strings
You can expect easy typed access to your translations like it should be. No hassle with typos or missing translations anymore. Enjoy!
"welcomeText" = "Hello %@, welcome in our app."; "close" = "Close";
// // Localizations.swift // // Generated code that contains the available keys from en.lproj/Localizable.strings // Copyright © 2020. All rights reserved. // import Foundation extension String { func localized(bundle: Bundle = .main, tableName: String = "Localizable") -> String { NSLocalizedString(self, tableName: tableName, bundle: bundle, value: self, comment: "") } func localizedWithFormat(bundle: Bundle = .main, tableName: String = "Localizable", args: CVarArg...) -> String { String.localizedStringWithFormat(self.localized(bundle: bundle, tableName: tableName), args) } } struct Localizations { private init() {} /// Base translation: Hello %@, welcome in our app. static func welcomeText(args: CVarArg...) -> String { "welcomeText".localizedWithFormat(args: args) } /// Base translation: Close static let close = "close".localized() }
Just include this generated file in your XCode project and rerun the script whenever the .strings file is updated.
.strings
open Package.swift
For running tests, just run swift test.
swift test
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
Typed Translations
this swift package will make it easy to enable typed access to your literals specified in the
Localizable.strings
file.Quick run
What to expect?
You can expect easy typed access to your translations like it should be. No hassle with typos or missing translations anymore. Enjoy!
Input
Output
Just include this generated file in your XCode project and rerun the script whenever the
.strings
file is updated.Where is my XCode project?
open Package.swift
to open this swift package.Tests
For running tests, just run
swift test
.