Selaa lähdekoodia

Missing strings etc. (#112)

Jon B Mårtensson 2 vuotta sitten
vanhempi
commit
f20a46df73

Tiedoston diff-näkymää rajattu, sillä se on liian suuri
+ 1 - 1
FreeAPS/Resources/javascript/bundle/determine-basal.js


+ 31 - 10
FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings

@@ -143,7 +143,7 @@
 "Save" = "Save";
 
 /*  */
-"Save as preset" = "Save as preset";
+"Save as Preset" = "Save as Preset";
 
 /* Delete Meal Preset */
 "Delete Preset" = "Delete Preset";
@@ -260,7 +260,7 @@ Enact a temp Basal or a temp target */
 /* */
 "Manual Temp Basal" = "Manual Temp Basal";
 
-/* Allow uploads tp NS */
+/* Allow uploads to different services */
 "Allow uploads" = "Allow uploads";
 
 /* API secret in NS */
@@ -1307,17 +1307,38 @@ Enact a temp Basal or a temp target */
 /* Hide pop-up */
 "Hide" = "Hide";
 
-/* Error string 1. Make translation very short! */
-"Predicted Glucose, %@ %@, is below threshold (%@!)" = "Predicted Glucose, %@ %@, is below threshold (%@!)";
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Predicted Glucose, " = "Predicted Glucose, ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"is predicted below threshold " = "is predicted below threshold ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"is below Threshold of " = "is below Threshold of ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Eventual Glucose > Target Glucose, but glucose is climbing slower than expected. Expected: " = "Eventual Glucose > Target Glucose, but glucose is climbing slower than expected. Expected: ";
+
+//* Bolus pop-up / Alert string. Make translations concise! */
+". Climbing: " = ". Climbing: ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Eventual Glucose > Target Glucose, but glucose is falling slower than expected. Expected: " = "Eventual Glucose > Target Glucose, but glucose is falling slower than expected. Expected: ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+". Falling: " = ". Falling: ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Eventual Glucose > Target Glucose, but glucose is changing faster than expected. Expected: " =  "Eventual Glucose > Target Glucose, but glucose is changing faster than expected. Expected: ";
 
-/* Error string 2. Make translation very short! */
-"Eventual Glucose > Target Glucose, but glucose is falling faster than expected. Expected: %@. Falling: %@" = "Eventual Glucose > Target Glucose, but glucose is falling faster than expected. Expected: %@. Falling: %@";
+/* Bolus pop-up / Alert string. Make translations concise! */
+". Changing: " = ". Changing: ";
 
-/* Error string 3. Make translation very short! */
-"Minimum predicted Glucose is %@ %@" = "Minimum predicted Glucose is %@ %@";
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Minimum predicted Glucose is " = "Minimum predicted Glucose is ";
 
-/* Error string 4. Make translation very short! */
-"Predicted Glucose %@ %@, is below Threshold of %@" = "Predicted Glucose %@ %@, is below Threshold of %@";
+/* Add insulin without bolusing alert */
+" without bolusing" = " without bolusing";
 
 /* -------------------------------------------------------------------------------------------
   DASH strings

+ 66 - 9
FreeAPS/Sources/Localizations/Main/sv.lproj/Localizable.strings

@@ -143,7 +143,7 @@
 "Save" = "Spara";
 
 /*  */
-"Save as preset" = "Spara som förval";
+"Save as Preset" = "Spara som förval";
 
 /* Delete Meal Preset */
 "Delete Preset" = "Radera Förval";
@@ -1143,6 +1143,9 @@ Enact a temp Basal or a temp target */
 /* Display fat and protein entities */
 "Fat & Protein" = "Fett & protein";
 
+/* FPU Setttings Title */
+"Fat and Protein" = "Omvandling";
+
 /* */
 "Hide Fat & Protein" = "Dölj fett & protein";
 
@@ -1271,6 +1274,37 @@ Enact a temp Basal or a temp target */
 
 /* */
 "Name Of Dish" = "Namn på rätt";
+"Currently no Override active" = "Inget undantag aktivt";
+
+/* */
+"Total Insulin Adjustment" = "Total justering av ditt insulinbehov";
+
+/* */
+"Override your Basal, ISF, CR and Target profiles" = "Ändra sparad basal, korrektionsfaktor, insulinkvot and målvärde med ett tillfäligt undantag";
+
+/* */
+"Enable indefinitely" = "Aktivera tillsvidare";
+
+/* */
+"Override Profiles" = "Aktivera tillfälligt undantag";
+
+/* */
+"Override Profile Target" = "Ändra målvärde";
+
+/* */
+"Disable SMBs" = "Stäng av autobolusar (SMBs)";
+
+/* */
+"Your profile basal insulin will be adjusted with the override percentage and your profile ISF and CR will be inversly adjusted with the percentage.\n\nIf you toggle off the override every profile setting will return to normal." = "Your profile basal insulin will be adjusted with the override percentage and your profile ISF and CR will be inversly adjusted with the percentage.\n\nIf you toggle off the override every profile setting will return to normal.";
+
+/* Service Section */
+"App Icons" = "Ikoner";
+
+/* */
+"iAPS Icon" = "iAPS - ikon";
+
+/* Service Section */
+"Statistics and Home View" = "Statistik och Diagram";
 
 /* Save Carbs and continue to bolus recommendation */
 "Save and continue" = "Spara och fortsätt";
@@ -1307,17 +1341,38 @@ Enact a temp Basal or a temp target */
 /* Hide pop-up */
 "Hide" = "Göm";
 
-/* Error string 1. Make translation very short! */
-"Predicted Glucose, %@ %@, is below threshold (%@!)" = "Blodsockerprognos, %@ %@, är lägre än (%@!)";
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Predicted Glucose, " = "Prognos, ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"is predicted below threshold " = "är under tröskelvärde ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"is below Threshold of " = "är under tröskelvärde ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Eventual Glucose > Target Glucose, but glucose is climbing slower than expected. Expected: " = "Prognos > Målvärde, men blodsocker stiger snabbare än väntat. Förväntat: ";
+
+//* Bolus pop-up / Alert string. Make translations concise! */
+". Climbing: " = ". Stiger: ";
 
-/* Error string 2. Make translation very short! */
-"Eventual Glucose > Target Glucose, but glucose is falling faster than expected. Expected: %@. Falling: %@" = "Blodsockerprognos > målvärde, med blodsockret sjunker snabbare än väntat. Förväntat: %@. Sjunker: %@";
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Eventual Glucose > Target Glucose, but glucose is falling slower than expected. Expected: " = "Prognos > Målvärde, men blodsocker sjunker snabbare än väntat. Förväntat: ";
 
-/* Error string 3. Make translation very short! */
-"Minimum predicted Glucose is %@ %@" = "Lägsta blodsockerprognos är %@ %@!";
+/* Bolus pop-up / Alert string. Make translations concise! */
+". Falling: " = ". Sjunker: ";
 
-/* Error string 4. Make translation very short! */
-"Predicted Glucose %@ %@, is below Threshold of %@" = "Blodsockerprognos %@ %@, är under tröskelvärde %@";
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Eventual Glucose > Target Glucose, but glucose is changing faster than expected. Expected: " =  "Prognos > Målvärde, men blodsocker ändras snabbare än väntat. Förväntat: ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+". Changing: " = ". Ändras: ";
+
+/* Bolus pop-up / Alert string. Make translations concise! */
+"Minimum predicted Glucose is " = "Lägsta prognos är ";
+
+/* Add insulin without bolusing alert */
+" without bolusing" = " utan att ge insulin";
 
 /* -------------------------------------------------------------------------------------------
   DASH strings
@@ -1461,6 +1516,8 @@ Enact a temp Basal or a temp target */
 /* ----------------------Statistics strings -------------------------------*/
 /* */
 
+/* */
+"Today" = "Idag";
 
 "Today" = "Idag";
 

+ 9 - 1
FreeAPS/Sources/Models/Suggestion.swift

@@ -23,7 +23,11 @@ struct Suggestion: JSON, Equatable {
     let insulin: Insulin?
     let current_target: Decimal?
     let insulinForManualBolus: Decimal?
-    let manualBolusErrorString: String?
+    let manualBolusErrorString: Decimal?
+    let minDelta: Decimal?
+    let expectedDelta: Decimal?
+    let minGuardBG: Decimal?
+    let minPredBG: Decimal?
 }
 
 struct Predictions: JSON, Equatable {
@@ -65,6 +69,10 @@ extension Suggestion {
         case current_target
         case insulinForManualBolus
         case manualBolusErrorString
+        case minDelta
+        case expectedDelta
+        case minGuardBG
+        case minPredBG
     }
 }
 

+ 22 - 5
FreeAPS/Sources/Modules/Bolus/BolusStateModel.swift

@@ -7,20 +7,24 @@ extension Bolus {
         @Injected() var apsManager: APSManager!
         @Injected() var broadcaster: Broadcaster!
         @Injected() var pumpHistoryStorage: PumpHistoryStorage!
+      
         @Published var amount: Decimal = 0
         @Published var insulinRecommended: Decimal = 0
         @Published var insulinRequired: Decimal = 0
         @Published var waitForSuggestion: Bool = false
         @Published var manual: Bool = false
         @Published var error: Bool = false
-        @Published var errorString: String = ""
-
+        @Published var errorString: Decimal = 0
         @Published var evBG: Int = 0
         @Published var insulin: Decimal = 0
         @Published var target: Decimal = 0
         @Published var isf: Decimal = 0
         @Published var percentage: Decimal = 0
-
+        @Published var threshold: Decimal = 0
+        @Published var minGuardBG: Decimal = 0
+        @Published var minDelta: Decimal = 0
+        @Published var expectedDelta: Decimal = 0
+        @Published var minPredBG: Decimal = 0
         @Published var units: GlucoseUnits = .mmolL
 
         var waitForSuggestionInitial: Bool = false
@@ -30,6 +34,8 @@ extension Bolus {
             broadcaster.register(SuggestionObserver.self, observer: self)
             units = settingsManager.settings.units
             percentage = settingsManager.settings.insulinReqPercentage
+            threshold = units == .mmolL ? settingsManager.preferences.threshold_setting.asMmolL : settingsManager.preferences
+                .threshold_setting
 
             if waitForSuggestionInitial {
                 apsManager.determineBasal()
@@ -92,6 +98,11 @@ extension Bolus {
 
                 // Manual Bolus recommendation screen after a carb entry (normally) yields a higher amount than the insulin reqiured amount computed for SMBs (auto boluses). Carbs combined with a manual bolus threfore now (test) uses the Eventual BG for glucose prediction, whereas the insulinReg for SMBs uses the minPredBG for glucose prediction (typically lower than Eventual BG).
 
+                var conversion: Decimal = 1.0
+                if self.units == .mmolL {
+                    conversion = 0.0555
+                }
+
                 self.evBG = self.provider.suggestion?.eventualBG ?? 0
                 self.insulin = self.provider.suggestion?.insulinForManualBolus ?? 0
                 self.target = self.provider.suggestion?.current_target ?? 0
@@ -101,8 +112,14 @@ extension Bolus {
                     self.insulinRecommended = self.insulin * (self.settingsManager.settings.insulinReqPercentage / 100)
                 } else { self.insulinRecommended = self.insulin }
 
-                self.errorString = self.provider.suggestion?.manualBolusErrorString ?? ""
-                if self.errorString.count > 8 { self.error = true }
+                self.errorString = self.provider.suggestion?.manualBolusErrorString ?? 0
+                if self.errorString != 0 {
+                    self.error = true
+                    self.minGuardBG = (self.provider.suggestion?.minGuardBG ?? 0) * conversion
+                    self.minDelta = (self.provider.suggestion?.minDelta ?? 0) * conversion
+                    self.expectedDelta = (self.provider.suggestion?.expectedDelta ?? 0) * conversion
+                    self.minPredBG = (self.provider.suggestion?.minPredBG ?? 0) * conversion
+                } else { self.error = false }
 
                 self.insulinRecommended = self.apsManager
                     .roundBolus(amount: max(self.insulinRecommended, 0))

+ 114 - 22
FreeAPS/Sources/Modules/Bolus/View/BolusRootView.swift

@@ -7,6 +7,7 @@ extension Bolus {
         let waitForSuggestion: Bool
         let manualBolus: Bool
         @StateObject var state = StateModel()
+
         @State private var isAddInsulinAlertPresented = false
         @State private var presentInfo = false
         @State private var displayError = false
@@ -20,6 +21,12 @@ extension Bolus {
             return formatter
         }
 
+        private var fractionDigits: Int {
+            if state.units == .mmolL {
+                return 1
+            } else { return 0 }
+        }
+
         var body: some View {
             Form {
                 Section {
@@ -70,13 +77,11 @@ extension Bolus {
                         }
                     }
                     header: { Text("Bolus") }
-
                     Section {
                         Button { state.add() }
                         label: { Text("Enact bolus") }
                             .disabled(state.amount <= 0)
                     }
-
                     Section {
                         if waitForSuggestion {
                             Button { state.showModal(for: nil) }
@@ -87,17 +92,39 @@ extension Bolus {
                                 .disabled(state.amount <= 0)
                         }
                     }
+                    .alert(isPresented: $isAddInsulinAlertPresented) {
+                        Alert(
+                            title: Text("Are you sure?"),
+                            message: Text(
+                                "Add " + formatter
+                                    .string(from: state.amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit") +
+                                    NSLocalizedString(" without bolusing", comment: "Add insulin without bolusing alert")
+                            ),
+                            primaryButton: .destructive(
+                                Text("Add"),
+                                action: {
+                                    state.addWithoutBolus()
+                                    isAddInsulinAlertPresented = false
+                                }
+                            ),
+                            secondaryButton: .cancel()
+                        )
+                    }
                 }
             }
-            .alert(isPresented: $isAddInsulinAlertPresented) {
-                let amount = formatter
-                    .string(from: state.amount as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit")
-                return Alert(
-                    title: Text("Are you sure?"),
-                    message: Text("Add \(amount) without bolusing"),
+            .alert(isPresented: $displayError) {
+                Alert(
+                    title: Text("Warning!"),
+                    message: Text("\n" + alertString() + NSLocalizedString(
+                        "\n\nTap 'Add' to continue with selected amount.",
+                        comment: "Alert text to confirm bolus amount to add"
+                    )),
                     primaryButton: .destructive(
                         Text("Add"),
-                        action: { state.addWithoutBolus() }
+                        action: {
+                            state.amount = state.insulinRecommended
+                            displayError = false
+                        }
                     ),
                     secondaryButton: .cancel()
                 )
@@ -141,15 +168,13 @@ extension Bolus {
                     HStack {
                         Text("Eventual Glucose").foregroundColor(.secondary)
                         let evg = state.units == .mmolL ? Decimal(state.evBG).asMmolL : Decimal(state.evBG)
-                        let fractionDigit = state.units == .mmolL ? 1 : 0
-                        Text(evg.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigit))))
+                        Text(evg.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))))
                         Text(state.units.rawValue).foregroundColor(.secondary)
                     }
                     HStack {
                         Text("Target Glucose").foregroundColor(.secondary)
                         let target = state.units == .mmolL ? state.target.asMmolL : state.target
-                        let fractionDigit = state.units == .mmolL ? 1 : 0
-                        Text(target.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigit))))
+                        Text(target.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))))
                         Text(state.units.rawValue).foregroundColor(.secondary)
                     }
                     HStack {
@@ -198,15 +223,14 @@ extension Bolus {
                     }
                 }
                 // Warning
-                VStack {
-                    Divider()
-                    if state.error, state.insulinRecommended > 0 {
-                        Text("Warning!").font(.callout).foregroundColor(.orange).bold()
-                        Text(NSLocalizedString(state.errorString, comment: "")).font(.caption)
+                if state.error, state.insulinRecommended > 0 {
+                    VStack(spacing: 5) {
                         Divider()
-                    }
-                }.padding(.horizontal, 10)
-                // Footer. Warning string .
+                        Text("Warning!").font(.callout).bold().foregroundColor(.orange)
+                        Text(alertString()).font(.footnote)
+                        Divider()
+                    }.padding(.horizontal, 10)
+                }
                 if !(state.error && state.insulinRecommended > 0) {
                     VStack {
                         Text(
@@ -224,12 +248,80 @@ extension Bolus {
             .background(
                 RoundedRectangle(cornerRadius: 8, style: .continuous)
                     .fill(Color(colorScheme == .dark ? UIColor.systemGray4 : UIColor.systemGray4))
+                // .fill(Color(.systemGray).gradient)  // A more prominent pop-up, but harder to read
             )
         }
+
+        // Localize the Oref0 error/warning strings
+        private func alertString() -> String {
+            switch state.errorString {
+            case 1:
+                return NSLocalizedString(
+                    "Predicted Glucose, ",
+                    comment: "Bolus pop-up / Alert string. Make translations concise!"
+                ) + state.minGuardBG
+                    .formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))) + " " + state.units
+                    .rawValue + ", " +
+                    NSLocalizedString(
+                        "is predicted below threshold ",
+                        comment: "Bolus pop-up / Alert string. Make translations concise!"
+                    ) + state
+                    .threshold.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))) + "!"
+            case 2:
+                return NSLocalizedString(
+                    "Predicted Glucose, ",
+                    comment: "Bolus pop-up / Alert string. Make translations concise!"
+                ) + state.minGuardBG
+                    .formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))) + " " + state.units
+                    .rawValue + ", " +
+                    NSLocalizedString(
+                        "is below Threshold of ",
+                        comment: "Bolus pop-up / Alert string. Make translations concise!"
+                    ) + state
+                    .threshold.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits)))
+            case 3:
+                return NSLocalizedString(
+                    "Eventual Glucose > Target Glucose, but glucose is climbing slower than expected. Expected: ",
+                    comment: "Bolus pop-up / Alert string. Make translations concise!"
+                ) +
+                    state.expectedDelta
+                    .formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))) +
+                    NSLocalizedString(". Climbing: ", comment: "Bolus pop-up / Alert string. Make translatons concise!") + state
+                    .minDelta.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits)))
+            case 4:
+                return NSLocalizedString(
+                    "Eventual Glucose > Target Glucose, but glucose is falling slower than expected. Expected: ",
+                    comment: "Bolus pop-up / Alert string. Make translations concise!"
+                ) +
+                    state.expectedDelta
+                    .formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))) +
+                    NSLocalizedString(". Falling: ", comment: "Bolus pop-up / Alert string. Make translations concise!") + state
+                    .minDelta.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits)))
+            case 5:
+                return NSLocalizedString(
+                    "Eventual Glucose > Target Glucose, but glucose is changing faster than expected. Expected: ",
+                    comment: "Bolus pop-up / Alert string. Make translations concise!"
+                ) +
+                    state.expectedDelta
+                    .formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))) +
+                    NSLocalizedString(". Changing: ", comment: "Bolus pop-up / Alert string. Make translations concise!") + state
+                    .minDelta.formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits)))
+            case 6:
+                return NSLocalizedString(
+                    "Minimum predicted Glucose is ",
+                    comment: "Bolus pop-up / Alert string. Make translations concise!"
+                ) + state
+                    .minPredBG
+                    .formatted(.number.grouping(.never).rounded().precision(.fractionLength(fractionDigits))) + " " + state
+                    .units
+                    .rawValue
+            default:
+                return "Ignore Warning..."
+            }
+        }
     }
 }
 
-// fix iOS 15 bug
 struct ActivityIndicator: UIViewRepresentable {
     @Binding var isAnimating: Bool
     let style: UIActivityIndicatorView.Style