From ba0fa896e1b534458c30234b0c8a353b5c0f01fa Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Fri, 2 Apr 2021 18:00:35 +0200 Subject: [PATCH] Remove hard coded strings from forms --- lib/l10n/app_en.arb | 14 ++++++++++++++ lib/widgets/workouts/forms.dart | 25 +++++++++++-------------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index c60a179a..99bea11d 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -97,6 +97,7 @@ "@rir": { "description": "Shorthand for Repetitions In Reserve" }, + "sameRepetitions": "If you do the same repetitions for all sets you can just fill in one value: e.g. for 4 sets just enter one \"10\" for the repetitions, this automatically becomes \"4 x 10\".", "comment": "Comment", "@comment": { "description": "Comment, additional information" @@ -119,6 +120,7 @@ "@newSet": { "description": "Header when adding a new set to a workout day" }, + "selectExercises": "You can search for more than one exercise, they will be grouped together for a superset.", "gymMode": "Gym mode", "@gymMode": { "description": "Label when starting the gym mode" @@ -260,6 +262,10 @@ "@enterValue": { "description": "Error message when the user hasn't entered a value on a required field" }, + "selectExercise": "Please select an exercise", + "@selectExercise": { + "description": "Error message when the user hasn't selected an exercise in the form" + }, "enterCharacters": "Please enter between {min} and {max} characters", "@enterCharacters": { "description": "Error message when the user hasn't entered the correct number of characters in a form", @@ -269,6 +275,14 @@ "max": {} } }, + "nrOfSets": "Number of sets: {nrOfSets}", + "@nrOfSets": { + "description": "Label shown on the slider where the user selects the nr of sets", + "type": "text", + "placeholders": { + "nrOfSets": {} + } + }, "enterValidNumber": "Please enter a valid number", "@enterValidNumber": { "description": "Error message when the user has submitted an invalid number (e.g. '3,.,.,.')" diff --git a/lib/widgets/workouts/forms.dart b/lib/widgets/workouts/forms.dart index 8fcf6383..e9efd52f 100644 --- a/lib/widgets/workouts/forms.dart +++ b/lib/widgets/workouts/forms.dart @@ -160,7 +160,7 @@ class _DayFormWidgetState extends State { const minLength = 5; const maxLength = 100; if (value!.isEmpty || value.length < minLength || value.length > maxLength) { - return 'Please enter between $minLength and $maxLength characters.'; + return AppLocalizations.of(context)!.enterCharacters(minLength, maxLength); } return null; }, @@ -257,8 +257,7 @@ class _SetFormWidgetState extends State { decoration: InputDecoration( labelText: AppLocalizations.of(context)!.exercise, helperMaxLines: 3, - helperText: 'You can search for more than one exercise, they will be grouped ' - 'together for a superset.'), + helperText: AppLocalizations.of(context)!.selectExercises), ), suggestionsCallback: (pattern) async { return await Provider.of(context, listen: false).searchExercise(pattern); @@ -295,13 +294,13 @@ class _SetFormWidgetState extends State { }, validator: (value) { if (value!.isEmpty) { - return 'Please select an exercise'; + return AppLocalizations.of(context)!.selectExercise; } return null; }, ), SizedBox(height: 10), - Text('Number of sets: ${_currentSetSliderValue.round()}'), + Text(AppLocalizations.of(context)!.nrOfSets(_currentSetSliderValue.round())), Slider( value: _currentSetSliderValue, min: 1, @@ -326,7 +325,7 @@ class _SetFormWidgetState extends State { }, ), SwitchListTile( - title: Text('More details'), + title: Text(AppLocalizations.of(context)!.toggleDetails), value: _detailed, onChanged: (value) { setState(() { @@ -334,9 +333,7 @@ class _SetFormWidgetState extends State { }); }, ), - Text('If you do the same repetitions for all sets you can just enter ' - 'one value: e.g. for 4 sets just enter one "10" for the repetitions, ' - 'this automatically becomes "4 x 10".'), + Text(AppLocalizations.of(context)!.sameRepetitions), ...widget._set.exercisesObj.map((exercise) { final settings = widget._set.settings.where((e) => e.exerciseObj.id == exercise.id).toList(); @@ -450,11 +447,11 @@ class ExerciseSetting extends StatelessWidget { Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - Text('Reps'), - if (_detailed) Text('Unit'), - Text('Weight'), - if (_detailed) Text('Weight unit'), - if (_detailed) Text('RiR'), + Text(AppLocalizations.of(context)!.repetitions), + if (_detailed) Text(AppLocalizations.of(context)!.unit), + Text(AppLocalizations.of(context)!.weight), + if (_detailed) Text(AppLocalizations.of(context)!.unit), + if (_detailed) Text(AppLocalizations.of(context)!.rir), ], ), getRow(),