From 044d0c803b0e8f337ee99f854aa0832cf4aa78c1 Mon Sep 17 00:00:00 2001 From: Dominic Drees Date: Thu, 24 Apr 2025 00:56:04 +0200 Subject: [PATCH] added more LocalizedStringKeys from tvos target, fixed some german translations --- Localizable.xcstrings | 4 ++-- .../Views/SettingsView/SettingsModel.swift | 18 +++++++++++++++++- SulfurTV/Views/SettingsView/SettingsView.swift | 14 +++++++------- 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/Localizable.xcstrings b/Localizable.xcstrings index ded6181..b4bdc7f 100644 --- a/Localizable.xcstrings +++ b/Localizable.xcstrings @@ -774,7 +774,7 @@ "de" : { "stringUnit" : { "state" : "translated", - "value" : "Info" + "value" : "Infos" } } } @@ -1054,7 +1054,7 @@ "de" : { "stringUnit" : { "state" : "translated", - "value" : "Medienplayer" + "value" : "Video Wiedergabe" } } } diff --git a/SulfurTV/Views/SettingsView/SettingsModel.swift b/SulfurTV/Views/SettingsView/SettingsModel.swift index aebac65..8e10ff9 100644 --- a/SulfurTV/Views/SettingsView/SettingsModel.swift +++ b/SulfurTV/Views/SettingsView/SettingsModel.swift @@ -11,8 +11,24 @@ enum SettingDestination: Hashable { case general, media, modules, trackers, data, logs, info } +extension LocalizedStringKey { + var stringKey: String? { + Mirror(reflecting: self).children.first(where: { $0.label == "key" })?.value as? String + } +} + struct Setting: Identifiable, Hashable { let id: Int - let title: String + let title: LocalizedStringKey let destination: SettingDestination + + func hash(into hasher: inout Hasher) { + hasher.combine(id) + hasher.combine(title.stringKey) + hasher.combine(destination) + } + + static func ==(lhs: Setting, rhs: Setting) -> Bool { + return lhs.id == rhs.id && lhs.title.stringKey == rhs.title.stringKey && lhs.destination == rhs.destination + } } diff --git a/SulfurTV/Views/SettingsView/SettingsView.swift b/SulfurTV/Views/SettingsView/SettingsView.swift index cac9849..3a286c2 100644 --- a/SulfurTV/Views/SettingsView/SettingsView.swift +++ b/SulfurTV/Views/SettingsView/SettingsView.swift @@ -12,13 +12,13 @@ struct SettingsView: View { let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? "BETA" private let settings: [Setting] = [ - Setting(id: 1, title: "General Preferences", destination: .general), - Setting(id: 2, title: "Media Player", destination: .media), - Setting(id: 3, title: "Modules", destination: .modules), - Setting(id: 4, title: "Trackers", destination: .trackers), - Setting(id: 5, title: "Data", destination: .data), - Setting(id: 6, title: "Logs", destination: .logs), - Setting(id: 7, title: "Info", destination: .info) + Setting(id: 1, title: LocalizedStringKey("General Preferences"), destination: .general), + Setting(id: 2, title: LocalizedStringKey("Media Player"), destination: .media), + Setting(id: 3, title: LocalizedStringKey("Modules"), destination: .modules), + Setting(id: 4, title: LocalizedStringKey("Trackers"), destination: .trackers), + Setting(id: 5, title: LocalizedStringKey("Data"), destination: .data), + Setting(id: 6, title: LocalizedStringKey("Logs"), destination: .logs), + Setting(id: 7, title: LocalizedStringKey("Info"), destination: .info) ] var body: some View {