mirror of
https://github.com/Novaloop-AG/element-x-ios.git
synced 2026-11-05 03:48:27 +00:00
Download SAS Strings Tool + Localised SAS emojis (#2409)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
|
||||
+4
@@ -38,6 +38,10 @@ enum SessionVerificationControllerProxyCallback {
|
||||
struct SessionVerificationEmoji: Hashable {
|
||||
let symbol: String
|
||||
let description: String
|
||||
|
||||
var localizedDescription: String {
|
||||
SASL10n.localizedDescription(for: description)
|
||||
}
|
||||
}
|
||||
|
||||
// sourcery: AutoMockable
|
||||
|
||||
Reference in New Issue
Block a user