Prechádzať zdrojové kódy

Units in Home/View/Header are now localized.

Jon Mårtensson 5 rokov pred
rodič
commit
fd222b4cd5

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

@@ -336,6 +336,15 @@
 /*  */
 "0 U/hr" = "0 U/hr";
 
+/* abbreviation for days */
+"d" = "d";
+
+/* abbreviation for hours */
+"h" = "h";
+
+/* abbreviation for minutes */
+"m" = "m";
+
 /* */
 "Autotune Conf" = "Autotune";
 

+ 10 - 6
FreeAPS/Sources/Modules/Home/View/Header/PumpView.swift

@@ -30,10 +30,13 @@ struct PumpView: View {
                         .frame(height: 8)
                         .foregroundColor(reservoirColor)
                     if reservoir == 0xDEAD_BEEF {
-                        Text("50+ U").font(.system(size: 12, weight: .bold))
+                        Text("50+ " + NSLocalizedString("U", comment: "Insulin unit")).font(.system(size: 12, weight: .bold))
                     } else {
-                        Text(reservoirFormatter.string(from: reservoir as NSNumber)! + " U")
-                            .font(.system(size: 12, weight: .bold))
+                        Text(
+                            reservoirFormatter
+                                .string(from: reservoir as NSNumber)! + NSLocalizedString(" U", comment: "Insulin unit")
+                        )
+                        .font(.system(size: 12, weight: .bold))
                     }
                 }
             }
@@ -74,14 +77,15 @@ struct PumpView: View {
         let minutes = Int(time / 1.minutes.timeInterval)
 
         if days >= 1 {
-            return "\(days)d \(hours)h"
+            return "\(days)" + NSLocalizedString("d", comment: "abbreviation for days") + " \(hours)" +
+                NSLocalizedString("h", comment: "abbreviation for hours")
         }
 
         if hours >= 1 {
-            return "\(hours)h"
+            return "\(hours)" + NSLocalizedString("h", comment: "abbreviation for hours")
         }
 
-        return "\(minutes)m"
+        return "\(minutes)" + NSLocalizedString("m", comment: "abbreviation for minutes")
     }
 
     private var batteryColor: Color {

+ 10 - 4
FreeAPS/Sources/Modules/Home/View/HomeRootView.swift

@@ -32,13 +32,19 @@ extension Home {
                 VStack(alignment: .leading, spacing: 12) {
                     // HStack {
                     // Text("").font(.caption2).foregroundColor(.secondary) // Was "IOB"
-                    Text((numberFormatter.string(from: (viewModel.suggestion?.iob ?? 0) as NSNumber) ?? "0") + " U")
-                        .font(.system(size: 12, weight: .bold))
+                    Text(
+                        (numberFormatter.string(from: (viewModel.suggestion?.iob ?? 0) as NSNumber) ?? "0") +
+                            NSLocalizedString(" U", comment: "Insulin unit")
+                    )
+                    .font(.system(size: 12, weight: .bold))
                     // }
                     // HStack {
                     // Text("").font(.caption2).foregroundColor(.secondary) // Was "COB"
-                    Text((numberFormatter.string(from: (viewModel.suggestion?.cob ?? 0) as NSNumber) ?? "0") + " g")
-                        .font(.system(size: 12, weight: .bold))
+                    Text(
+                        (numberFormatter.string(from: (viewModel.suggestion?.cob ?? 0) as NSNumber) ?? "0") +
+                            NSLocalizedString(" g", comment: "gram of carbs")
+                    )
+                    .font(.system(size: 12, weight: .bold))
                     // }
                 }
                 Spacer()