Download SAS Strings Tool + Localised SAS emojis (#2409)

This commit is contained in:
Mauro
2024-01-31 13:29:52 +01:00
committed by GitHub
parent 7fa9cf16e2
commit 1a8fd7d8ff
16 changed files with 816 additions and 2 deletions
@@ -0,0 +1,27 @@
import Foundation
enum SASL10n {
static func localizedDescription(for key: String) -> String {
tr("SAS", key)
}
private static func tr(_ table: String, _ key: String, _ args: CVarArg...) -> String {
// Use preferredLocalizations to get a language that is in the bundle and the user's preferred list of languages.
let languages = Bundle.overrideLocalizations ?? Bundle.app.preferredLocalizations
for language in languages {
if let translation = trIn(language, table, key, args) {
return translation
}
}
return Bundle.app.developmentLocalization.flatMap { trIn($0, table, key, args) } ?? key
}
private static func trIn(_ language: String, _ table: String, _ key: String, _ args: CVarArg...) -> String? {
guard let bundle = Bundle.lprojBundle(for: language) else { return nil }
let format = NSLocalizedString(key, tableName: table, bundle: bundle, comment: "")
let translation = String(format: format, locale: Locale(identifier: language), arguments: args)
guard translation != key else { return nil }
return translation
}
}
@@ -204,7 +204,7 @@ struct SessionVerificationScreen: View {
VStack(spacing: 16.0) {
Text(emoji.symbol)
.font(.compound.headingXLBold)
Text(emoji.description)
Text(emoji.localizedDescription)
.font(.compound.bodyMD)
.foregroundColor(.compound.textSecondary)
}
@@ -38,6 +38,10 @@ enum SessionVerificationControllerProxyCallback {
struct SessionVerificationEmoji: Hashable {
let symbol: String
let description: String
var localizedDescription: String {
SASL10n.localizedDescription(for: description)
}
}
// sourcery: AutoMockable