Commit 34baea7

derdilla <derdilla06@gmail.com>
2023-06-11 07:48:17
add missing dropdown translations
1 parent a511f8d
lib/components/display_interval_picker.dart
@@ -32,7 +32,7 @@ class IntervalPicker extends StatelessWidget {
               }
             },
             items: TimeStep.options.map<DropdownMenuItem<int>>((v) {
-              return DropdownMenuItem(value: v, child: Text(TimeStep.getName(v)));
+              return DropdownMenuItem(value: v, child: Text(TimeStep.getName(v, context)));
             }).toList(),
           ),
         ),
lib/l10n/app_de.arb
@@ -42,11 +42,11 @@
   "btnUndo": "ZURÜCK",
 
   "sysLong": "Systole",
-  "sysShort": "sys",
+  "sysShort": "Sys",
   "diaLong": "Diastole",
-  "diaShort": "dia",
+  "diaShort": "Dia",
   "pulLong": "Puls",
-  "pulShort": "pul",
+  "pulShort": "Pul",
   "addNote": "Notiz (optional)",
 
   "layout": "Layout",
@@ -136,5 +136,11 @@
   "time": "Zeitpunkt",
   "confirmDelete": "Löschen bestätigen",
   "confirmDeleteDesc": "Soll der Eintrag wirklich gelöscht werden? (Diese Rückfrage kann in den Einstellungen abgestellt werden.)",
-  "deletionConfirmed": "Eintrag wurde gelöscht"
+  "deletionConfirmed": "Eintrag wurde gelöscht",
+
+  "day": "Tag",
+  "week": "Woche",
+  "month": "Monat",
+  "year": "Jahr",
+  "lifetime": "Lebenszeit"
 }
\ No newline at end of file
lib/l10n/app_en.arb
@@ -135,5 +135,11 @@
   "time": "time",
   "confirmDelete": "Confirm deletion",
   "confirmDeleteDesc": "Do you really want to delete this entry? You can turn of this question in the settings.",
-  "deletionConfirmed": "entry has been deleted"
+  "deletionConfirmed": "entry has been deleted",
+
+  "day": "day",
+  "week": "week",
+  "month": "month",
+  "year": "year",
+  "lifetime": "lifetime"
 }
\ No newline at end of file
lib/model/settings_store.dart
@@ -1,5 +1,6 @@
 import 'package:blood_pressure_app/model/blood_pressure.dart';
 import 'package:flutter/material.dart';
+import 'package:flutter_gen/gen_l10n/app_localizations.dart';
 import 'package:shared_preferences/shared_preferences.dart';
 
 class Settings extends ChangeNotifier {
@@ -291,20 +292,21 @@ class TimeStep {
 
   TimeStep._create();
 
-  static String getName(int opt) { // TODO: translations
+  static String getName(int opt, BuildContext context) {
     switch (opt) {
       case day:
-        return 'day';
+        return AppLocalizations.of(context)!.day;
       case month:
-        return 'month';
+        return AppLocalizations.of(context)!.month;
       case year:
-        return 'year';
+        return AppLocalizations.of(context)!.year;
       case lifetime:
-        return 'lifetime';
+        return AppLocalizations.of(context)!.lifetime;
       case week:
-        return 'week';
+        return AppLocalizations.of(context)!.week;
     }
-    return 'invalid';
+    assert(false);
+    return '-';
   }
 }
 
test/model/settings_test.dart
@@ -8,16 +8,6 @@ void main() {
   TestWidgetsFlutterBinding.ensureInitialized();
   SharedPreferences.setMockInitialValues({});
 
-  group('TimeStep', () {
-    test('names should match to fields', () {
-      expect(TimeStep.getName(TimeStep.day), 'day');
-      expect(TimeStep.getName(TimeStep.week), 'week');
-      expect(TimeStep.getName(TimeStep.month), 'month');
-      expect(TimeStep.getName(TimeStep.year), 'year');
-      expect(TimeStep.getName(TimeStep.lifetime), 'lifetime');
-    });
-  });
-
   group('Settings model', () {
     // setup db path
     databaseFactory = databaseFactoryFfi;