Self hosted FLOSS fitness/workout, nutrition and weight tracker
Update helper texts in extract-i18n.py
Roland Geider9c10069861fd
diff --git a/wger/core/management/commands/extract-i18n.py b/wger/core/management/commands/extract-i18n.pyindex fd2fedc2c..63c945dd7 100644--- a/wger/core/management/commands/extract-i18n.py+++ b/wger/core/management/commands/extract-i18n.py@@ -53,6 +53,10 @@ class Command(BaseCommand):+ [i.name_en for i in Muscle.objects.all() if i.name_en] \+ [i for i in RepetitionUnit.objects.all()]+ # Make entries unique+ data = set([i.__str__() for i in data])++ ## Django - write to .tpl filewith open('wger/i18n.tpl', 'w') as f:out = '{% load i18n %}\n'@@ -62,13 +66,13 @@ class Command(BaseCommand):self.stdout.write(self.style.SUCCESS(f'Wrote content to i18n.tpl!'))#- # React - write to .tsx file (copy the file into the react repo)+ # React - copy the file to src/i18n.tsx in the react repowith open('wger/i18n.tsx', 'w') as f:out = '''import { useTranslation } from "react-i18next";- export const DummyComponent = () => {- const [t, i18n] = useTranslation();'''+ const DummyComponent = () => {+ const [t] = useTranslation();'''for i in data:out += f't("exercises.{cleanup_name(i.__str__())}");\n'@@ -79,7 +83,7 @@ class Command(BaseCommand):self.stdout.write(self.style.SUCCESS(f'Wrote content to i18n.tsx!'))#- # Flutter - write to app_en.arb, copy to the end of app_en.arb in the flutter repo+ # Flutter - copy content to the end of lib/l10n/app_en.arb in the flutter repowith open('wger/app_en.arb', 'w') as f:out = ''for i in data:@@ -87,9 +91,19 @@ class Command(BaseCommand):f.write(out)self.stdout.write(self.style.SUCCESS(f'Wrote content to app_en.arb!'))- # Copy to i18n.dart in the flutter repo+ # Copy to lib/helpers/i18n.dart in the flutter repowith open('wger/i18n.dart', 'w') as f:- out = '''String getTranslation(String value, BuildContext context) {+ out = '''+ import 'package:flutter/widgets.dart';+ import 'package:flutter_gen/gen_l10n/app_localizations.dart';+ /// This code is autogenerated in the backend repo in extract-i18n.py do not edit!++ /// Translate dynamic strings that are returned from the server+ /// These strings such as categories or equipment are returned by the server+ /// in English and need to be translated here in the application (there are+ /// probably better ways to do this, but that's the way it is right now).++ String getTranslation(String value, BuildContext context) {switch (value) {'''for i in data:out += f'''@@ -97,10 +111,10 @@ class Command(BaseCommand):return AppLocalizations.of(context).{cleanup_name(i.__str__())};'''- out += f'''default:+ out += '''default:return 'NOT TRANSLATED';}}}}'''f.write(out)- self.stdout.write(self.style.SUCCESS(f'Wrote content to i18n.dart!'))+ self.stdout.write(self.style.SUCCESS('Wrote content to i18n.dart!'))diff --git a/wger/i18n.tpl b/wger/i18n.tplindex 656739299..7d7a3cca9 100644--- a/wger/i18n.tpl+++ b/wger/i18n.tpl@@ -1,35 +1,31 @@{% load i18n %}+{% translate "Lower back" %}+{% translate "Seconds" %}+{% translate "Repetitions" %}+{% translate "Dumbbell" %}{% translate "Abs" %}-{% translate "Arms" %}-{% translate "Back" %}-{% translate "Calves" %}-{% translate "Chest" %}-{% translate "Legs" %}+{% translate "SZ-Bar" %}+{% translate "Miles" %}+{% translate "Kilometers" %}{% translate "Shoulders" %}+{% translate "Triceps" %}+{% translate "Quads" %}+{% translate "none (bodyweight exercise)" %}{% translate "Barbell" %}-{% translate "Bench" %}-{% translate "Dumbbell" %}+{% translate "Lats" %}+{% translate "Until Failure" %}{% translate "Gym mat" %}-{% translate "Incline bench" %}-{% translate "Kettlebell" %}+{% translate "Glutes" %}+{% translate "Bench" %}{% translate "Pull-up bar" %}-{% translate "SZ-Bar" %}-{% translate "Swiss Ball" %}-{% translate "none (bodyweight exercise)" %}-{% translate "Shoulders" %}-{% translate "Biceps" %}-{% translate "Hamstrings" %}-{% translate "Lower back" %}{% translate "Calves" %}-{% translate "Glutes" %}-{% translate "Lats" %}+{% translate "Arms" %}+{% translate "Biceps" %}+{% translate "Kettlebell" %}+{% translate "Back" %}{% translate "Chest" %}-{% translate "Quads" %}-{% translate "Abs" %}-{% translate "Triceps" %}-{% translate "Kilometers" %}-{% translate "Miles" %}+{% translate "Swiss Ball" %}{% translate "Minutes" %}-{% translate "Repetitions" %}-{% translate "Seconds" %}-{% translate "Until Failure" %}+{% translate "Incline bench" %}+{% translate "Hamstrings" %}+{% translate "Legs" %}