Ver código fonte

Add missing strings to String Catalogue via proper syntax

Deniz Cengiz 1 ano atrás
pai
commit
2a349b733b

+ 1 - 1
LiveActivity/Views/WidgetItems/LiveActivityCOBLabelView.swift

@@ -22,7 +22,7 @@ struct LiveActivityCOBLabelView: View {
                     .foregroundStyle(context.isStale ? .secondary : .primary)
                     .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))
 
-                Text("g")
+                Text(String(localized: "g", comment: "gram of carbs"))
                     .font(.headline).fontWeight(.bold)
                     .foregroundStyle(context.isStale ? .secondary : .primary)
                     .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))

+ 1 - 1
LiveActivity/Views/WidgetItems/LiveActivityIOBLabelView.swift

@@ -30,7 +30,7 @@ struct LiveActivityIOBLabelView: View {
                 .foregroundStyle(context.isStale ? .secondary : .primary)
                 .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))
 
-                Text("U")
+                Text(String(localized: "U", comment: "Insulin unit"))
                     .font(.headline).fontWeight(.bold)
                     .foregroundStyle(context.isStale ? .secondary : .primary)
                     .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))

+ 1 - 1
LiveActivity/Views/WidgetItems/LiveActivityTotalDailyDoseView.swift

@@ -24,7 +24,7 @@ struct LiveActivityTotalDailyDoseView: View {
                 .foregroundStyle(context.isStale ? .secondary : .primary)
                 .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))
 
-                Text("U")
+                Text(String(localized: "U", comment: "Insulin unit"))
                     .font(.headline).fontWeight(.bold)
                     .foregroundStyle(context.isStale ? .secondary : .primary)
                     .strikethrough(context.isStale, pattern: .solid, color: .red.opacity(0.6))

+ 1 - 1
Trio Watch App Extension/Views/BolusConfirmationView.swift

@@ -37,7 +37,7 @@ struct BolusConfirmationView: View {
                 HStack {
                     Text("Bolus")
                     Spacer()
-                    Text(String(format: "%.2f U", adjustedBolusAmount))
+                    Text(String(format: "%.2f \(String(localized: "U", comment: "Insulin unit"))", adjustedBolusAmount))
                         .bold()
                         .foregroundStyle(Color.insulin)
                 }.padding(.horizontal)

+ 8 - 2
Trio Watch App Extension/Views/BolusInputView.swift

@@ -25,7 +25,10 @@ struct BolusInputView: View {
     var body: some View {
         VStack {
             if state.showBolusCalculationProgress {
-                ProgressView("Calculating Bolus...")
+                ProgressView(String(
+                    localized: "Calculating Bolus...",
+                    comment: "Progress view text on watch when calculating bolus"
+                ))
                 Spacer()
             } else {
                 if effectiveBolusLimit <= 0 {
@@ -117,7 +120,10 @@ struct BolusInputView: View {
                     .tint(Color.insulin)
                     .disabled(!(bolusAmount > 0.0) || bolusAmount > effectiveBolusLimit)
 
-                    Text(String(format: "Recommended: %.1f U", NSDecimalNumber(decimal: state.recommendedBolus).doubleValue))
+                    Text(String(
+                        format: "\(String(localized: "Recommended:", comment: "Recommended bolus on Watch")) %.1f \(String(localized: "U", comment: "Insulin unit"))",
+                        NSDecimalNumber(decimal: state.recommendedBolus).doubleValue
+                    ))
                         .font(.footnote)
                         .foregroundStyle(.secondary)
                 }

+ 4 - 1
Trio Watch App Extension/Views/BolusProgressOverlay.swift

@@ -47,7 +47,10 @@ struct BolusProgressOverlay: View {
                     .tint(progressGradient)
 
                 Text(String(
-                    format: "%.2f U of %.2f U",
+                    format: String(
+                        localized: "%.2f U of %.2f U",
+                        comment: "Format for showing delivered and active bolus amounts, 'x U of y U' on watch"
+                    ),
                     state.deliveredAmount,
                     state.activeBolusAmount
                 ))

+ 3 - 2
Trio Watch App Extension/Views/CarbsInputView.swift

@@ -22,7 +22,8 @@ struct CarbsInputView: View {
     )
 
     var body: some View {
-        let buttonLabel = continueToBolus ? "Proceed" : "Log Carbs"
+        let buttonLabel = continueToBolus ? String(localized: "Proceed", comment: "Button Label to Proceed to Bolus on Watch") :
+            String(localized: "Log Carbs", comment: "Button Label to Log Carbs on Watch")
 
         // TODO: introduce meal setting fpu enablement to conditional handle FPU
         VStack {
@@ -45,7 +46,7 @@ struct CarbsInputView: View {
                 Spacer()
 
                 // Display the current carb amount
-                Text(String(format: "%.0f g", carbsAmount))
+                Text(String(format: "%.0f \(String(localized: "g", comment: "gram of carbs"))", carbsAmount))
                     .fontWeight(.bold)
                     .font(.system(.title2, design: .rounded))
                     .foregroundColor(carbsAmount > 0.0 && carbsAmount >= effectiveCarbsLimit ? .loopRed : .primary)

+ 8 - 3
Trio Watch App Extension/Views/GlucoseTrendView.swift

@@ -148,9 +148,14 @@ struct GlucoseTrendView: View {
 
             Spacer()
 
-            Text(isWatchStateDated ? "STALE DATA" : state.lastLoopTime ?? "--")
-                .font(.system(size: minutesAgoFontSize))
-                .fontWidth(isWatchStateDated ? .expanded : .standard)
+            Text(
+                isWatchStateDated ?
+                    String(localized: "STALE DATA", comment: "Information displayed when watch app data outdated or stale.") :
+                    state
+                    .lastLoopTime ?? "--"
+            )
+            .font(.system(size: minutesAgoFontSize))
+            .fontWidth(isWatchStateDated ? .expanded : .standard)
 
             Spacer()
 

+ 3 - 3
Trio Watch App Extension/Views/TreatmentMenuView.swift

@@ -103,9 +103,9 @@ enum TreatmentOption: String, CaseIterable, Identifiable {
 
     var displayName: String {
         switch self {
-        case .mealBolusCombo: return "Meal & Bolus"
-        case .meal: return "Meal"
-        case .bolus: return "Bolus"
+        case .mealBolusCombo: return String(localized: "Meal & Bolus", comment: "Watch App Treatment Option 'Meal & Bolus'")
+        case .meal: return String(localized: "Meal", comment: "Watch App Treatment Option 'Meal'")
+        case .bolus: return String(localized: "Bolus", comment: "Watch App Treatment Option 'Bolus'")
         }
     }
 }

+ 11 - 5
Trio/Sources/APS/APSManager.swift

@@ -452,7 +452,7 @@ final class BaseAPSManager: APSManager, Injectable {
                     $0.bolusDidFail()
                 }
             }
-            callback?(false, "Error! Failed to enact bolus.")
+            callback?(false, String(localized: "Error! Failed to enact bolus.", comment: "Error message for enacting a bolus"))
             return
         }
 
@@ -469,7 +469,7 @@ final class BaseAPSManager: APSManager, Injectable {
                 await determineBasalSync()
             }
             bolusProgress.send(0)
-            callback?(true, "Bolus enacted successfully.")
+            callback?(true, String(localized: "Bolus enacted successfully.", comment: "Success message for enacting a bolus"))
         } catch {
             warning(.apsManager, "Bolus failed with error: \(error.localizedDescription)")
             processError(APSError.pumpError(error))
@@ -480,7 +480,10 @@ final class BaseAPSManager: APSManager, Injectable {
                     }
                 }
             }
-            callback?(false, "Error! Failed to enact bolus.")
+            callback?(
+                false,
+                String(localized: "Error! Failed to enact bolus.", comment: "Error message for failing to enact a bolus")
+            )
         }
     }
 
@@ -490,11 +493,14 @@ final class BaseAPSManager: APSManager, Injectable {
         do {
             _ = try await pump.cancelBolus()
             debug(.apsManager, "Bolus cancelled")
-            callback?(true, "Bolus cancelled successfully.")
+            callback?(true, String(localized: "Bolus cancelled successfully.", comment: "Success message for canceling a bolus"))
         } catch {
             debug(.apsManager, "Bolus cancellation failed with error: \(error.localizedDescription)")
             processError(APSError.pumpError(error))
-            callback?(false, "Error! Bolus cancellation failed.")
+            callback?(
+                false,
+                String(localized: "Error! Bolus cancellation failed.", comment: "Error message for canceling a bolus")
+            )
         }
         bolusReporter?.removeObserver(self)
         bolusReporter = nil

+ 63 - 3
Trio/Sources/Localizations/Main/Localizable.xcstrings

@@ -2203,6 +2203,9 @@
         }
       }
     },
+    " of " : {
+      "comment" : "Bolus string partial message: 'x U of y U' in home view"
+    },
     " SMBs are disabled either by schedule or during the entire duration." : {
       "comment" : "Alert string. Keep spaces.",
       "extractionState" : "manual",
@@ -5573,6 +5576,17 @@
         }
       }
     },
+    "%.2f U of %.2f U" : {
+      "comment" : "Format for showing delivered and active bolus amounts, 'x U of y U' on watch",
+      "localizations" : {
+        "en" : {
+          "stringUnit" : {
+            "state" : "new",
+            "value" : "%1$.2f U of %2$.2f U"
+          }
+        }
+      }
+    },
     "%@" : {
       "comment" : "Info message\nunits",
       "localizations" : {
@@ -36026,7 +36040,7 @@
       }
     },
     "Bolus" : {
-      "comment" : "Treatment type",
+      "comment" : "Treatment type\nWatch App Treatment Option 'Bolus'",
       "localizations" : {
         "ar" : {
           "stringUnit" : {
@@ -36238,6 +36252,12 @@
         }
       }
     },
+    "Bolus cancelled successfully." : {
+      "comment" : "Success message for canceling a bolus"
+    },
+    "Bolus enacted successfully." : {
+      "comment" : "Success message for enacting a bolus"
+    },
     "Bolus failed" : {
       "comment" : "Bolus failed",
       "localizations" : {
@@ -37898,7 +37918,7 @@
       }
     },
     "Calculating Bolus..." : {
-
+      "comment" : "Progress view text on watch when calculating bolus"
     },
     "Calculations" : {
       "comment" : "For the  Bolus View pop-up",
@@ -40089,6 +40109,9 @@
         }
       }
     },
+    "Carbs and Bolus logged successfully." : {
+      "comment" : "Successful message sent to watch when logging carbs and bolus"
+    },
     "Carbs and previous insulin are included in the glucose prediction, but if the Eventual Glucose is lower than the Target Glucose, a bolus will not be recommended." : {
       "comment" : "Bolus pop-up footer",
       "extractionState" : "manual",
@@ -40206,6 +40229,9 @@
     "Carbs Limit Reached!" : {
 
     },
+    "Carbs logged successfully." : {
+      "comment" : "Success message sent to watch when carbs are logged successfully"
+    },
     "Carbs Req Threshold" : {
       "comment" : "Headline \"Carbs Req Threshold\"",
       "extractionState" : "manual",
@@ -69722,6 +69748,9 @@
         }
       }
     },
+    "Enacting bolus..." : {
+      "comment" : "Successful message sent to watch when enacting bolus"
+    },
     "end" : {
       "localizations" : {
         "ar" : {
@@ -71123,6 +71152,12 @@
         }
       }
     },
+    "Error! Bolus cancellation failed." : {
+      "comment" : "Error message for canceling a bolus"
+    },
+    "Error! Failed to enact bolus." : {
+      "comment" : "Error message for enacting a bolus\nError message for failing to enact a bolus"
+    },
     "Errors" : {
       "comment" : "Loop Errors in statPanel",
       "extractionState" : "manual",
@@ -79306,7 +79341,7 @@
       }
     },
     "g" : {
-      "comment" : "The short unit display string for grams",
+      "comment" : "The short unit display string for grams\ngram of carbs",
       "localizations" : {
         "ar" : {
           "stringUnit" : {
@@ -90590,6 +90625,9 @@
         }
       }
     },
+    "Importing Profile..." : {
+      "comment" : "Progress text when importing profile via Nightscout"
+    },
     "In case you're using both profiles and temp targets" : {
       "comment" : "UI/UX option",
       "extractionState" : "manual",
@@ -98339,6 +98377,7 @@
       }
     },
     "Log Carbs" : {
+      "comment" : "Button Label to Log Carbs on Watch",
       "localizations" : {
         "ar" : {
           "stringUnit" : {
@@ -105740,6 +105779,9 @@
         }
       }
     },
+    "Meal & Bolus" : {
+      "comment" : "Watch App Treatment Option 'Meal & Bolus'"
+    },
     "Meal Presets" : {
       "localizations" : {
         "ar" : {
@@ -124017,6 +124059,9 @@
         }
       }
     },
+    "Proceed" : {
+      "comment" : "Button Label to Proceed to Bolus on Watch"
+    },
     "Processing…" : {
 
     },
@@ -127926,6 +127971,9 @@
         }
       }
     },
+    "Recommended:" : {
+      "comment" : "Recommended bolus on Watch"
+    },
     "Red = Below Range" : {
       "localizations" : {
         "ar" : {
@@ -132163,6 +132211,9 @@
         }
       }
     },
+    "Saving Carbs..." : {
+      "comment" : "Successful message sent to watch when saving carbs"
+    },
     "Saving..." : {
       "comment" : "button title for saving low reservoir reminder while saving",
       "localizations" : {
@@ -143606,6 +143657,9 @@
         }
       }
     },
+    "STALE DATA" : {
+      "comment" : "Information displayed when watch app data outdated or stale."
+    },
     "Standing / Laying TIR Chart" : {
       "localizations" : {
         "ar" : {
@@ -171145,6 +171199,9 @@
     "Updated:" : {
 
     },
+    "Updating IOB..." : {
+      "comment" : "Progress text when updating IOB"
+    },
     "Updating..." : {
       "comment" : "Updating Watch app",
       "extractionState" : "manual",
@@ -173558,6 +173615,9 @@
         }
       }
     },
+    "Via Watch" : {
+      "comment" : "Note added to carb entry when entered via watch"
+    },
     "Wait please" : {
       "extractionState" : "manual",
       "localizations" : {

+ 2 - 2
Trio/Sources/Modules/Home/View/HomeRootView.swift

@@ -758,7 +758,7 @@ extension Home {
                 let bolusFraction = progress * (bolusTotal as Decimal)
                 let bolusString =
                     (bolusProgressFormatter.string(from: bolusFraction as NSNumber) ?? "0")
-                        + " of " +
+                        + String(localized: " of ", comment: "Bolus string partial message: 'x U of y U' in home view") +
                         (Formatter.decimalFormatterWithTwoFractionDigits.string(from: bolusTotal as NSNumber) ?? "0")
                         + String(localized: " U", comment: "Insulin unit")
 
@@ -1099,7 +1099,7 @@ extension Home {
                 tabBar()
 
                 if state.waitForSuggestion {
-                    CustomProgressView(text: "Updating IOB...")
+                    CustomProgressView(text: String(localized: "Updating IOB...", comment: "Progress text when updating IOB"))
                 }
             }
         }

+ 4 - 1
Trio/Sources/Modules/NightscoutConfig/View/NightscoutConfigRootView.swift

@@ -174,7 +174,10 @@ extension NightscoutConfig {
                 .blur(radius: state.importStatus == .running ? 5 : 0)
 
                 if state.importStatus == .running {
-                    CustomProgressView(text: "Importing Profile...")
+                    CustomProgressView(text: String(
+                        localized: "Importing Profile...",
+                        comment: "Progress text when importing profile via Nightscout"
+                    ))
                 }
             }
             .fullScreenCover(isPresented: $state.isImportResultReviewPresented, content: {

+ 27 - 6
Trio/Sources/Services/WatchManager/AppleWatchManager.swift

@@ -632,7 +632,7 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
                 carbEntry.id = UUID()
                 carbEntry.carbs = Double(truncating: amount as NSNumber)
                 carbEntry.date = date
-                carbEntry.note = "Via Watch"
+                carbEntry.note = String(localized: "Via Watch", comment: "Note added to carb entry when entered via watch")
                 carbEntry.isFPU = false // set this to false to ensure watch-entered carbs are displayed in main chart
                 carbEntry.isUploadedToNS = false
 
@@ -642,7 +642,13 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
                     debug(.watchManager, "📱 Saved carbs from watch: \(amount)g at \(date)")
 
                     // Acknowledge success
-                    self.sendAcknowledgment(toWatch: true, message: "Carbs logged successfully.")
+                    self.sendAcknowledgment(
+                        toWatch: true,
+                        message: String(
+                            localized: "Carbs logged successfully.",
+                            comment: "Success message sent to watch when carbs are logged successfully"
+                        )
+                    )
                 } catch {
                     debug(.watchManager, "❌ Error saving carbs: \(error.localizedDescription)")
 
@@ -664,7 +670,10 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
 
             do {
                 // Notify Watch: "Saving carbs..."
-                self.sendAcknowledgment(toWatch: true, message: "Saving Carbs...")
+                self.sendAcknowledgment(
+                    toWatch: true,
+                    message: String(localized: "Saving Carbs...", comment: "Successful message sent to watch when saving carbs")
+                )
 
                 // Save carbs entry in Core Data
                 try await context.perform {
@@ -672,7 +681,7 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
                     carbEntry.id = UUID()
                     carbEntry.carbs = NSDecimalNumber(decimal: carbsAmount).doubleValue
                     carbEntry.date = date
-                    carbEntry.note = "Via Watch"
+                    carbEntry.note = String(localized: "Via Watch", comment: "Note added to carb entry when entered via watch")
                     carbEntry.isFPU = false // set this to false to ensure watch-entered carbs are displayed in main chart
                     carbEntry.isUploadedToNS = false
 
@@ -682,7 +691,13 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
                 }
 
                 // Notify Watch: "Enacting bolus..."
-                sendAcknowledgment(toWatch: true, message: "Enacting bolus...")
+                sendAcknowledgment(
+                    toWatch: true,
+                    message: String(
+                        localized: "Enacting bolus...",
+                        comment: "Successful message sent to watch when enacting bolus"
+                    )
+                )
 
                 // Enact bolus via APS Manager
                 let bolusDouble = NSDecimalNumber(decimal: bolusAmount).doubleValue
@@ -692,7 +707,13 @@ final class BaseWatchManager: NSObject, WCSessionDelegate, Injectable, WatchMana
                 }
                 debug(.watchManager, "📱 Enacted bolus from watch via APS Manager: \(bolusDouble) U")
                 // Notify Watch: "Carbs and bolus logged successfully"
-                sendAcknowledgment(toWatch: true, message: "Carbs and Bolus logged successfully.")
+                sendAcknowledgment(
+                    toWatch: true,
+                    message: String(
+                        localized: "Carbs and Bolus logged successfully.",
+                        comment: "Successful message sent to watch when logging carbs and bolus"
+                    )
+                )
 
             } catch {
                 debug(.watchManager, "❌ Error processing combined request: \(error.localizedDescription)")