Kaynağa Gözat

Merge pull request #391 from dsnallfot/more-localizations

Localization of Shortcuts and progress view strings + Minor fix for new stats view
Deniz Cengiz 1 yıl önce
ebeveyn
işleme
4a1d7ee1d5

+ 22 - 6
Trio/Sources/Helpers/CustomProgressView.swift

@@ -43,10 +43,26 @@ struct CustomProgressView: View {
     }
 }
 
-enum ProgressText: String {
-    case updatingIOB = "Updating IOB ..."
-    case updatingCOB = "Updating COB ..."
-    case updatingHistory = "Updating History ..."
-    case updatingTreatments = "Updating Treatments ..."
-    case updatingIOBandCOB = "Updating IOB and COB ..."
+enum ProgressText: CaseIterable {
+    case updatingIOB
+    case updatingCOB
+    case updatingHistory
+    case updatingTreatments
+    case updatingIOBandCOB
+
+    var displayName: String {
+        switch self {
+        case .updatingIOB:
+            return String(localized: "Updating IOB ...", comment: "Status message for updating IOB")
+        case .updatingCOB:
+
+            return String(localized: "Updating COB ...", comment: "Status message for updating COB")
+        case .updatingHistory:
+            return String(localized: "Updating History ...", comment: "Status message for updating history")
+        case .updatingTreatments:
+            return String(localized: "Updating Treatments ...", comment: "Status message for updating treatments")
+        case .updatingIOBandCOB:
+            return String(localized: "Updating IOB and COB ...", comment: "Status message for updating both IOB and COB")
+        }
+    }
 }

+ 99 - 2
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -17320,6 +17320,9 @@
         }
       }
     },
+    "A bolus command of %@ U of insulin was sent." : {
+
+    },
     "A display of On/On indicates both Dynamic ISF and CR are enabled. On/Off indicates only Dynamic ISF is enabled. Dynamic CR cannot be enabled when Dynamic ISF is disabled." : {
       "localizations" : {
         "bg" : {
@@ -18736,6 +18739,9 @@
         }
       }
     },
+    "Activate an override" : {
+
+    },
     "Activate Dynamic Carb Ratio (CR)" : {
       "comment" : "Enable Dyn CR",
       "localizations" : {
@@ -28959,6 +28965,9 @@
         }
       }
     },
+    "Allow to send a bolus to the app" : {
+
+    },
     "Allow Trio to read from and write to Apple Health." : {
       "localizations" : {
         "bg" : {
@@ -33549,6 +33558,9 @@
         }
       }
     },
+    "Applying ${bolusQuantity} U" : {
+
+    },
     "Applying ${carbQuantity} at ${dateAdded}" : {
       "localizations" : {
         "bg" : {
@@ -33749,6 +33761,9 @@
         }
       }
     },
+    "Applying ${preset} override" : {
+
+    },
     "Are you sure to add %@ g of carbs ?" : {
       "localizations" : {
         "bg" : {
@@ -33849,6 +33864,9 @@
         }
       }
     },
+    "Are you sure you want to bolus %@ U of insulin?" : {
+
+    },
     "Are you sure you want to delete %@?" : {
       "localizations" : {
         "bg" : {
@@ -39712,6 +39730,12 @@
         }
       }
     },
+    "Bolus amount (units of insulin)?" : {
+
+    },
+    "Bolus amount in U" : {
+
+    },
     "Bolus Calculator" : {
       "localizations" : {
         "bg" : {
@@ -41158,6 +41182,9 @@
         }
       }
     },
+    "Bolusing via Shortcuts is disabled in Trio settings." : {
+
+    },
     "Bottom target" : {
       "comment" : "Bottom target temp",
       "extractionState" : "manual",
@@ -43016,6 +43043,9 @@
         }
       }
     },
+    "Cancel an active override" : {
+
+    },
     "Cancel Bolus" : {
       "localizations" : {
         "bg" : {
@@ -43116,6 +43146,9 @@
         }
       }
     },
+    "Cancel override" : {
+
+    },
     "Cancel Override" : {
       "localizations" : {
         "bg" : {
@@ -51609,6 +51642,9 @@
         }
       }
     },
+    "Confirm to apply override '%@'" : {
+
+    },
     "Confirm to apply Temporary Target '%@'" : {
       "localizations" : {
         "bg" : {
@@ -88913,7 +88949,7 @@
       }
     },
     "Glucose" : {
-      "comment" : "Glucose\nHistory Mode",
+      "comment" : "Glucose\nHistory Mode\nTitle for glucose-related statistics",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -96844,6 +96880,9 @@
         }
       }
     },
+    "If toggled, you will need to confirm before applying." : {
+
+    },
     "If using Dynamic ISF (with Sigmoid), overriding your ISF will adjust the ISF used at your glucose target which extends to the ISF used at other glucose. Overriding your glucose target will change glucose level your ISF will be set to your profile ISF. Both of these can be combined in a single Override." : {
       "localizations" : {
         "bg" : {
@@ -97650,6 +97689,9 @@
         }
       }
     },
+    "Immediately applying ${bolusQuantity} U" : {
+
+    },
     "Immediately applying ${carbQuantity} at ${dateAdded}" : {
       "localizations" : {
         "bg" : {
@@ -97850,6 +97892,9 @@
         }
       }
     },
+    "Immediately applying ${preset} override" : {
+
+    },
     "Import Error" : {
       "comment" : "Import Error HeadlineImport Error Headline",
       "extractionState" : "manual",
@@ -100519,6 +100564,7 @@
       }
     },
     "Insulin" : {
+      "comment" : "Title for insulin-related statistics",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -109328,6 +109374,9 @@
         }
       }
     },
+    "Looping" : {
+      "comment" : "Title for looping and system statistics"
+    },
     "Looping Chart Type" : {
 
     },
@@ -112333,6 +112382,9 @@
         }
       }
     },
+    "Max bolus" : {
+
+    },
     "Max Bolus" : {
       "comment" : "Max setting",
       "localizations" : {
@@ -116432,7 +116484,7 @@
 
     },
     "Meals" : {
-      "comment" : "History Mode",
+      "comment" : "History Mode\nTitle for meal-related statistics",
       "localizations" : {
         "bg" : {
           "stringUnit" : {
@@ -124482,6 +124534,9 @@
         }
       }
     },
+    "Not allowed" : {
+
+    },
     "Not paired yet" : {
       "extractionState" : "manual",
       "localizations" : {
@@ -130605,6 +130660,18 @@
         }
       }
     },
+    "Override '%@' applied" : {
+
+    },
+    "Override '%@' failed" : {
+
+    },
+    "Override canceled" : {
+
+    },
+    "Override choice" : {
+
+    },
     "Override eA1c Unit" : {
 
     },
@@ -142205,6 +142272,9 @@
     "Restart Live Activity" : {
 
     },
+    "Restarts Trio's Live Activity" : {
+
+    },
     "Result" : {
       "comment" : "For the  Bolus View pop-up",
       "localizations" : {
@@ -146928,6 +146998,9 @@
         }
       }
     },
+    "Select override" : {
+
+    },
     "Select Pump Model" : {
       "localizations" : {
         "bg" : {
@@ -165156,6 +165229,12 @@
         }
       }
     },
+    "Temporary Target '%@' applied" : {
+
+    },
+    "Temporary Target '%@' failed" : {
+
+    },
     "Temporary Target canceled" : {
       "localizations" : {
         "bg" : {
@@ -165763,6 +165842,9 @@
         }
       }
     },
+    "The bolus cannot be larger than the pump setting max bolus (%@)." : {
+
+    },
     "The current version has a critical issue and should be updated as soon as possible." : {
       "comment" : "Message for critical update alert",
       "localizations" : {
@@ -186411,6 +186493,18 @@
         }
       }
     },
+    "Updating COB ..." : {
+      "comment" : "Status message for updating COB"
+    },
+    "Updating History ..." : {
+      "comment" : "Status message for updating history"
+    },
+    "Updating IOB ..." : {
+      "comment" : "Status message for updating IOB"
+    },
+    "Updating IOB and COB ..." : {
+      "comment" : "Status message for updating both IOB and COB"
+    },
     "Updating IOB..." : {
       "comment" : "Progress text when updating IOB",
       "localizations" : {
@@ -186512,6 +186606,9 @@
         }
       }
     },
+    "Updating Treatments ..." : {
+      "comment" : "Status message for updating treatments"
+    },
     "Updating..." : {
       "comment" : "Updating Watch app",
       "extractionState" : "manual",

+ 2 - 2
Trio/Sources/Models/TrioSettings.swift

@@ -8,9 +8,9 @@ enum BolusShortcutLimit: String, JSON, CaseIterable, Identifiable {
     var displayName: String {
         switch self {
         case .notAllowed:
-            return String(localized: "Not allowed", table: "ShortcutsDetail")
+            return String(localized: "Not allowed")
         case .limitBolusMax:
-            return String(localized: "Max bolus", table: "ShortcutsDetail")
+            return String(localized: "Max bolus")
         }
     }
 }

+ 1 - 1
Trio/Sources/Modules/DataTable/View/DataTableRootView.swift

@@ -101,7 +101,7 @@ extension DataTable {
                 // Show custom progress view
                 /// don't show it if glucose is stale as it will block the UI
                 if state.waitForSuggestion && state.isGlucoseDataFresh(glucoseStored.first?.date) {
-                    CustomProgressView(text: progressText.rawValue)
+                    CustomProgressView(text: progressText.displayName)
                 }
             })
                 .background(appState.trioBackgroundColor(for: colorScheme))

+ 8 - 4
Trio/Sources/Modules/Stat/StatStateModel.swift

@@ -327,10 +327,14 @@ extension Stat.StateModel {
 
         var displayName: String {
             switch self {
-            case .glucose: return "Glucose"
-            case .insulin: return "Insulin"
-            case .looping: return "Looping"
-            case .meals: return "Meals"
+            case .glucose:
+                return String(localized: "Glucose", comment: "Title for glucose-related statistics")
+            case .insulin:
+                return String(localized: "Insulin", comment: "Title for insulin-related statistics")
+            case .looping:
+                return String(localized: "Looping", comment: "Title for looping and system statistics")
+            case .meals:
+                return String(localized: "Meals", comment: "Title for meal-related statistics")
             }
         }
     }

+ 2 - 2
Trio/Sources/Modules/Stat/View/StatRootView.swift

@@ -176,7 +176,7 @@ extension Stat {
 
             Picker("Duration", selection: $state.selectedIntervalForInsulinStats) {
                 ForEach(StateModel.StatsTimeInterval.allCases) { timeInterval in
-                    Text(timeInterval.rawValue).tag(timeInterval)
+                    Text(timeInterval.displayName).tag(timeInterval)
                 }
             }
             .pickerStyle(.segmented)
@@ -316,7 +316,7 @@ extension Stat {
 
             Picker("Duration", selection: $state.selectedIntervalForMealStats) {
                 ForEach(StateModel.StatsTimeInterval.allCases, id: \.self) { timeInterval in
-                    Text(timeInterval.rawValue)
+                    Text(timeInterval.displayName)
                 }
             }
             .pickerStyle(.segmented)

+ 1 - 1
Trio/Sources/Modules/Treatments/View/TreatmentsRootView.swift

@@ -347,7 +347,7 @@ extension Treatments {
                 .blur(radius: state.isAwaitingDeterminationResult ? 5 : 0)
 
                 if state.isAwaitingDeterminationResult {
-                    CustomProgressView(text: progressText.rawValue)
+                    CustomProgressView(text: progressText.displayName)
                 }
             }
             .padding(.top)

+ 18 - 16
Trio/Sources/Shortcuts/Bolus/BolusIntent.swift

@@ -5,38 +5,39 @@ import Swinject
 
 @available(iOS 16.0,*) struct BolusIntent: AppIntent {
     // Title of the action in the Shortcuts app
-    static var title = LocalizedStringResource("Enact Bolus", table: "ShortcutsDetail")
+    static var title = LocalizedStringResource("Enact Bolus")
 
     // Description of the action in the Shortcuts app
-    static var description = IntentDescription(.init("Allow to send a bolus to the app", table: "ShortcutsDetail"))
+    static var description = IntentDescription(.init("Allow to send a bolus to the app"))
 
     @Parameter(
-        title: LocalizedStringResource("Amount", table: "ShortcutsDetail"),
-        description: LocalizedStringResource("Bolus amount in U", table: "ShortcutsDetail"),
+        title: LocalizedStringResource("Amount"),
+        description: LocalizedStringResource("Bolus amount in U"),
         controlStyle: .field,
         /// The 200 upperBound does nothing here, the true max is set based on pump max
         /// An upperBound is specificed so that we can usethe lowerBound of 0, which ensures no negatives are allowed
         /// A preferred approach would be to just block negatives and not specify an upperBound here, since it is implemented elsewhere
         inclusiveRange: (lowerBound: 0, upperBound: 200),
-        requestValueDialog: IntentDialog(LocalizedStringResource(
-            "Bolus amount (units of insulin)?",
-            table: "ShortcutsDetail"
-        ))
+        requestValueDialog: IntentDialog(
+            LocalizedStringResource(
+                "Bolus amount (units of insulin)?"
+            )
+        )
     ) var bolusQuantity: Double
 
     @Parameter(
-        title: LocalizedStringResource("Confirm Before applying", table: "ShortcutsDetail"),
-        description: LocalizedStringResource("If toggled, you will need to confirm before applying.", table: "ShortcutsDetail"),
+        title: LocalizedStringResource("Confirm Before applying"),
+        description: LocalizedStringResource("If toggled, you will need to confirm before applying."),
         default: true
     ) var confirmBeforeApplying: Bool
 
     static var parameterSummary: some ParameterSummary {
         When(\.$confirmBeforeApplying, .equalTo, true, {
-            Summary("Applying \(\.$bolusQuantity) U", table: "ShortcutsDetail") {
+            Summary("Applying \(\.$bolusQuantity) U") {
                 \.$confirmBeforeApplying
             }
         }, otherwise: {
-            Summary("Immediately applying \(\.$bolusQuantity) U", table: "ShortcutsDetail") {
+            Summary("Immediately applying \(\.$bolusQuantity) U") {
                 \.$confirmBeforeApplying
             }
         })
@@ -50,10 +51,11 @@ import Swinject
             if confirmBeforeApplying {
                 try await requestConfirmation(
                     result: .result(
-                        dialog: IntentDialog(LocalizedStringResource(
-                            "Are you sure you want to bolus \(bolusFormatted) U of insulin?",
-                            table: "ShortcutsDetail"
-                        ))
+                        dialog: IntentDialog(
+                            LocalizedStringResource(
+                                "Are you sure you want to bolus \(bolusFormatted) U of insulin?"
+                            )
+                        )
                     )
                 )
             }

+ 3 - 6
Trio/Sources/Shortcuts/Bolus/BolusIntentRequest.swift

@@ -9,24 +9,21 @@ import Foundation
         // Block boluses if they are disabled
         case .notAllowed:
             return LocalizedStringResource(
-                "Bolusing via Shortcuts is disabled in Trio settings.",
-                table: "ShortcutsDetail"
+                "Bolusing via Shortcuts is disabled in Trio settings."
             )
 
         // Block any bolus attempted if it is larger than the max bolus in settings
         case .limitBolusMax:
             if Decimal(bolusAmount) > settingsManager.pumpSettings.maxBolus {
                 return LocalizedStringResource(
-                    "The bolus cannot be larger than the pump setting max bolus (\(settingsManager.pumpSettings.maxBolus.description)).",
-                    table: "ShortcutsDetail"
+                    "The bolus cannot be larger than the pump setting max bolus (\(settingsManager.pumpSettings.maxBolus.description))."
                 )
             } else {
                 bolusQuantity = apsManager.roundBolus(amount: Decimal(bolusAmount))
             }
             await apsManager.enactBolus(amount: Double(bolusQuantity), isSMB: false, callback: nil)
             return LocalizedStringResource(
-                "A bolus command of \(bolusQuantity.formatted()) U of insulin was sent.",
-                table: "ShortcutsDetail"
+                "A bolus command of \(bolusQuantity.formatted()) U of insulin was sent."
             )
         }
     }

+ 2 - 2
Trio/Sources/Shortcuts/LiveActivity/RestartLiveActivityIntent.swift

@@ -6,10 +6,10 @@ import Foundation
 /// dependencies injected via Swinject, and calls the restart functionality.
 @available(iOS 16.2, *) struct RestartLiveActivityIntent: LiveActivityIntent {
     /// Title of the action in the Shortcuts app.
-    static var title = LocalizedStringResource("Restart Live Activity", table: "ShortcutsDetail")
+    static var title = LocalizedStringResource("Restart Live Activity")
 
     /// Description of the action in the Shortcuts app.
-    static var description = IntentDescription(.init("Restarts Trio's Live Activity", table: "ShortcutsDetail"))
+    static var description = IntentDescription(.init("Restarts Trio's Live Activity"))
 
     /// Performs the intent by triggering the live activity restart.
     ///

+ 16 - 17
Trio/Sources/Shortcuts/Override/ApplyOverridePresetIntent.swift

@@ -4,32 +4,32 @@ import Foundation
 /// An App Intent that allows users to activate an override preset through the Shortcuts app.
 struct ApplyOverridePresetIntent: AppIntent {
     /// The title displayed for this action in the Shortcuts app.
-    static var title = LocalizedStringResource("Activate an override", table: "ShortcutsDetail")
+    static var title = LocalizedStringResource("Activate an override")
 
     /// The description displayed for this action in the Shortcuts app.
-    static var description = IntentDescription(.init("Activate an override", table: "ShortcutsDetail"))
+    static var description = IntentDescription(.init("Activate an override"))
 
     /// The override preset to be applied.
     @Parameter(
-        title: LocalizedStringResource("Override", table: "ShortcutsDetail"),
-        description: LocalizedStringResource("Override choice", table: "ShortcutsDetail")
+        title: LocalizedStringResource("Override"),
+        description: LocalizedStringResource("Override choice")
     ) var preset: OverridePreset?
 
     /// A boolean parameter that determines whether confirmation is required before applying the override.
     @Parameter(
-        title: LocalizedStringResource("Confirm Before applying", table: "ShortcutsDetail"),
-        description: LocalizedStringResource("If toggled, you will need to confirm before applying", table: "ShortcutsDetail"),
+        title: LocalizedStringResource("Confirm Before applying"),
+        description: LocalizedStringResource("If toggled, you will need to confirm before applying"),
         default: true
     ) var confirmBeforeApplying: Bool
 
     /// Defines the summary format shown in the Shortcuts app when configuring this intent.
     static var parameterSummary: some ParameterSummary {
         When(\ApplyOverridePresetIntent.$confirmBeforeApplying, .equalTo, true, {
-            Summary("Applying \(\.$preset) override", table: "ShortcutsDetail") {
+            Summary("Applying \(\.$preset) override") {
                 \.$confirmBeforeApplying
             }
         }, otherwise: {
-            Summary("Immediately applying \(\.$preset) override", table: "ShortcutsDetail") {
+            Summary("Immediately applying \(\.$preset) override") {
                 \.$confirmBeforeApplying
             }
         })
@@ -49,7 +49,7 @@ struct ApplyOverridePresetIntent: AppIntent {
                 // Request user selection if no preset is provided
                 presetToApply = try await $preset.requestDisambiguation(
                     among: await OverridePresetsIntentRequest().fetchAndProcessOverrides(),
-                    dialog: IntentDialog(LocalizedStringResource("Select override", table: "ShortcutsDetail"))
+                    dialog: IntentDialog(LocalizedStringResource("Select override"))
                 )
             }
 
@@ -59,10 +59,11 @@ struct ApplyOverridePresetIntent: AppIntent {
             if confirmBeforeApplying {
                 try await requestConfirmation(
                     result: .result(
-                        dialog: IntentDialog(LocalizedStringResource(
-                            "Confirm to apply override '\(displayName)'",
-                            table: "ShortcutsDetail"
-                        ))
+                        dialog: IntentDialog(
+                            LocalizedStringResource(
+                                "Confirm to apply override '\(displayName)'"
+                            )
+                        )
                     )
                 )
             }
@@ -72,8 +73,7 @@ struct ApplyOverridePresetIntent: AppIntent {
                 return .result(
                     dialog: IntentDialog(
                         LocalizedStringResource(
-                            "Override '\(presetToApply.name)' applied",
-                            table: "ShortcutsDetail"
+                            "Override '\(presetToApply.name)' applied"
                         )
                     )
                 )
@@ -81,8 +81,7 @@ struct ApplyOverridePresetIntent: AppIntent {
                 return .result(
                     dialog: IntentDialog(
                         LocalizedStringResource(
-                            "Override '\(presetToApply.name)' failed",
-                            table: "ShortcutsDetail"
+                            "Override '\(presetToApply.name)' failed"
                         )
                     )
                 )

+ 3 - 3
Trio/Sources/Shortcuts/Override/CancelOverrideIntent.swift

@@ -4,10 +4,10 @@ import Foundation
 /// An App Intent that allows users to cancel an active override through the Shortcuts app.
 struct CancelOverrideIntent: AppIntent {
     /// The title displayed for this action in the Shortcuts app.
-    static var title = LocalizedStringResource("Cancel override", table: "ShortcutsDetail")
+    static var title = LocalizedStringResource("Cancel override")
 
     /// The description displayed for this action in the Shortcuts app.
-    static var description = IntentDescription(.init("Cancel an active override", table: "ShortcutsDetail"))
+    static var description = IntentDescription(.init("Cancel an active override"))
 
     /// Performs the intent action to cancel an active override.
     ///
@@ -16,7 +16,7 @@ struct CancelOverrideIntent: AppIntent {
     @MainActor func perform() async throws -> some ProvidesDialog {
         await OverridePresetsIntentRequest().cancelOverride()
         return .result(
-            dialog: IntentDialog(LocalizedStringResource("Override canceled", table: "ShortcutsDetail"))
+            dialog: IntentDialog(LocalizedStringResource("Override canceled"))
         )
     }
 }

+ 2 - 4
Trio/Sources/Shortcuts/TempPresets/ApplyTempPresetIntent.swift

@@ -80,8 +80,7 @@ struct ApplyTempPresetIntent: AppIntent {
                 return .result(
                     dialog: IntentDialog(
                         LocalizedStringResource(
-                            "Temporary Target '\(presetToApply.name)' applied",
-                            table: "ShortcutsDetail"
+                            "Temporary Target '\(presetToApply.name)' applied"
                         )
                     )
                 )
@@ -89,8 +88,7 @@ struct ApplyTempPresetIntent: AppIntent {
                 return .result(
                     dialog: IntentDialog(
                         LocalizedStringResource(
-                            "Temporary Target '\(presetToApply.name)' failed",
-                            table: "ShortcutsDetail"
+                            "Temporary Target '\(presetToApply.name)' failed"
                         )
                     )
                 )