Просмотр исходного кода

Localize GlucoseNotificationsOption enum cases

dsnallfot 1 год назад
Родитель
Сommit
2497c58d2c

+ 7 - 9
Trio/Sources/Models/GlucoseNotificationsOption.swift

@@ -5,18 +5,16 @@
 //  Created by Kimberlie Skandis on 1/18/25.
 //
 import Foundation
+import SwiftUI
 
 public enum GlucoseNotificationsOption: String, JSON, CaseIterable, Identifiable, Codable, Hashable {
+    case disabled = "Disabled"
+    case alwaysEveryCGM = "Always"
+    case onlyAlarmLimits = "Only Alarm Limits"
+
     public var id: String { rawValue }
-    case disabled
-    case alwaysEveryCGM
-    case onlyAlarmLimits
 
-    var displayName: String {
-        switch self {
-        case .disabled: return "Disabled"
-        case .alwaysEveryCGM: return "Always"
-        case .onlyAlarmLimits: return "Only Alarm Limits"
-        }
+    var localized: LocalizedStringKey {
+        LocalizedStringKey(rawValue)
     }
 }

+ 1 - 1
Trio/Sources/Modules/GlucoseNotificationSettings/View/GlucoseNotificationSettingsRootView.swift

@@ -197,7 +197,7 @@ extension GlucoseNotificationSettings {
                             label: Text("Glucose Notifications")
                         ) {
                             ForEach(GlucoseNotificationsOption.allCases) { selection in
-                                Text(selection.displayName).tag(selection)
+                                Text(selection.localized).tag(selection)
                             }
                         }.padding(.top)