mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-25 17:45:19 +00:00
Fix Localizations (#684)
* Update all `NSLocalizedString` with `L10n.string` + combine with `L10n.format` * Handle Localizations + Swift Package
This commit is contained in:
@@ -1,12 +1,21 @@
|
||||
import Foundation
|
||||
|
||||
enum L10n {
|
||||
static func string(_ key: String, comment: String) -> String {
|
||||
NSLocalizedString(key, comment: comment)
|
||||
static func string(_ key: String, comment: String, _ args: CVarArg...) -> String {
|
||||
let basic = NSLocalizedString(key, bundle: .localization, comment: comment)
|
||||
if args.isEmpty {
|
||||
return basic
|
||||
}
|
||||
return String(format: basic, locale: .current, arguments: args)
|
||||
}
|
||||
}
|
||||
|
||||
static func format(_ key: String, comment: String, _ args: CVarArg...) -> String {
|
||||
let format = NSLocalizedString(key, comment: comment)
|
||||
return String(format: format, locale: Locale.current, arguments: args)
|
||||
private extension Bundle {
|
||||
static var localization: Bundle {
|
||||
#if SWIFT_PACKAGE
|
||||
return Bundle.module
|
||||
#else
|
||||
return Bundle.main
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user