Przeglądaj źródła

Localize "day(s)" (#428)

Jon B Mårtensson 4 lat temu
rodzic
commit
5699fb8d94

+ 2 - 2
Dependencies/LibreTransmitter/Sources/LibreTransmitter/LibreSensor/SensorContents/SensorData.swift

@@ -201,12 +201,12 @@ public struct SensorData: Codable {
 
     var humanReadableSensorAge: String {
         let days = TimeInterval(minutesSinceStart * 60) / aday
-        return String(format: "%.2f", days) + " day(s)"
+        return String(format: "%.2f", days) + NSLocalizedString(" day(s)", comment: "Sensor day(s)")
     }
 
     var humanReadableTimeLeft: String {
         let days = TimeInterval(minutesLeft * 60) / aday
-        return String(format: "%.2f", days) + " day(s)"
+        return String(format: "%.2f", days) + NSLocalizedString(" day(s)", comment: "Sensor day(s)")
     }
 
     var toJson: String {

+ 13 - 5
Dependencies/LibreTransmitter/Sources/LibreTransmitter/LibreTransmitterManager.swift

@@ -258,7 +258,7 @@ extension LibreTransmitterManager {
                 let aday = 86_400.0 //in seconds
                 var humanReadableSensorAge: String {
                     let days = TimeInterval(bleData.age * 60) / aday
-                    return String(format: "%.2f", days) + " day(s)"
+                    return String(format: "%.2f", days) + NSLocalizedString(" day(s)", comment: "Sensor day(s)")
                 }
 
 
@@ -273,7 +273,7 @@ extension LibreTransmitterManager {
 
                 var humanReadableTimeLeft: String {
                     let days = TimeInterval(minutesLeft * 60) / aday
-                    return String(format: "%.2f", days) + " day(s)"
+                    return String(format: "%.2f", days) + NSLocalizedString(" day(s)", comment: "Sensor day(s)")
                 }
 
                 //once the sensor has ended we don't know the exact date anymore
@@ -447,7 +447,7 @@ extension LibreTransmitterManager {
             glucose += LibreGlucose.fromHistoryMeasurements(sortedHistory, nativeCalibrationData: calibrationData)
         }*/
 
-        let newGlucose = glucosesToSamplesFilter(glucose, startDate: getStartDateForFilter())
+        var newGlucose = glucosesToSamplesFilter(glucose, startDate: getStartDateForFilter())
 
         if newGlucose.isEmpty {
             self.countTimesWithoutData &+= 1
@@ -459,6 +459,10 @@ extension LibreTransmitterManager {
 
         //todo: predictions also for libre2 bluetooth data
         //self.latestPrediction = prediction?.first
+        var predictions: [LibreGlucose] = []
+
+        overcalibrate(entries: &newGlucose, prediction: &predictions)
+
         self.setObservables(sensorData: nil, bleData: bleData, metaData: device)
 
         self.logger.debug("dabear:: handleGoodReading returned with \(newGlucose.count) entries")
@@ -638,6 +642,12 @@ extension LibreTransmitterManager {
             entries += LibreGlucose.fromHistoryMeasurements(history, nativeCalibrationData: calibration)
         }
 
+        overcalibrate(entries: &entries, prediction: &prediction)
+
+        return (glucose: entries, prediction: prediction)
+    }
+
+    private func overcalibrate(entries: inout [LibreGlucose], prediction: inout [LibreGlucose]) {
         // overcalibrate
         var overcalibration: ((Double) -> (Double))? = nil
         delegateQueue.sync { overcalibration = cgmManagerDelegate?.overcalibration(for: self) }
@@ -654,8 +664,6 @@ extension LibreTransmitterManager {
             entries = overcalibrate(entries: entries)
             prediction = overcalibrate(entries: prediction)
         }
-
-        return (glucose: entries, prediction: prediction)
     }
 
     public func handleGoodReading(data: SensorData?, _ callback: @escaping (LibreError?, GlucoseArrayWithPrediction?) -> Void) {

+ 6 - 19
FreeAPS.xcodeproj/xcshareddata/xcschemes/FreeAPSWatch.xcscheme

@@ -55,10 +55,8 @@
       debugServiceExtension = "internal"
       allowLocationSimulation = "YES"
       notificationPayloadFile = "FreeAPSWatch WatchKit Extension/PushNotificationPayload.apns">
-      <RemoteRunnable
-         runnableDebuggingMode = "2"
-         BundleIdentifier = "com.apple.Carousel"
-         RemotePath = "/FreeAPS X">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "38E8751B27554D5500975559"
@@ -66,7 +64,7 @@
             BlueprintName = "FreeAPSWatch"
             ReferencedContainer = "container:FreeAPS.xcodeproj">
          </BuildableReference>
-      </RemoteRunnable>
+      </BuildableProductRunnable>
    </LaunchAction>
    <ProfileAction
       buildConfiguration = "Release"
@@ -74,10 +72,8 @@
       savedToolIdentifier = ""
       useCustomWorkingDirectory = "NO"
       debugDocumentVersioning = "YES">
-      <RemoteRunnable
-         runnableDebuggingMode = "2"
-         BundleIdentifier = "com.apple.Carousel"
-         RemotePath = "/FreeAPS X">
+      <BuildableProductRunnable
+         runnableDebuggingMode = "0">
          <BuildableReference
             BuildableIdentifier = "primary"
             BlueprintIdentifier = "38E8751B27554D5500975559"
@@ -85,16 +81,7 @@
             BlueprintName = "FreeAPSWatch"
             ReferencedContainer = "container:FreeAPS.xcodeproj">
          </BuildableReference>
-      </RemoteRunnable>
-      <MacroExpansion>
-         <BuildableReference
-            BuildableIdentifier = "primary"
-            BlueprintIdentifier = "38E8751B27554D5500975559"
-            BuildableName = "FreeAPSWatch.app"
-            BlueprintName = "FreeAPSWatch"
-            ReferencedContainer = "container:FreeAPS.xcodeproj">
-         </BuildableReference>
-      </MacroExpansion>
+      </BuildableProductRunnable>
    </ProfileAction>
    <AnalyzeAction
       buildConfiguration = "Debug">

+ 3 - 0
FreeAPS/Sources/Localizations/Main/en.lproj/Localizable.strings

@@ -896,6 +896,9 @@ Enact a temp Basal or a temp target */
 /* */
 "Animated Background" = "Animated Background";
 
+/* Sensor day(s) */
+" day(s)" = " day(s)";
+
 
 /* Headers for settings ----------------------- */
 "OpenAPS main settings" = "OpenAPS main settings";