Просмотр исходного кода

Units and abbreviations now localized in Home/View/Header.

Jon Mårtensson 4 лет назад
Родитель
Сommit
076a9d8d35

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

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

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

@@ -328,6 +328,15 @@
 /* when 0 U/hr */
 "0 U/hr" = "0 IE/h";
 
+/* 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("IOB").font(.caption2).foregroundColor(.secondary)
-                        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("COB").font(.caption2).foregroundColor(.secondary)
-                        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()