From 6e8ccf078ab74ac0529f5f4b3564eb25897a69b1 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 6 Dec 2023 12:25:16 +0100 Subject: [PATCH] Log a warning if a translation couldn't be loaded in the flutter app --- wger/core/management/commands/extract-i18n.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/wger/core/management/commands/extract-i18n.py b/wger/core/management/commands/extract-i18n.py index c3e1d3017..bd46424e0 100644 --- a/wger/core/management/commands/extract-i18n.py +++ b/wger/core/management/commands/extract-i18n.py @@ -114,8 +114,11 @@ def cleanup_name(text: str) -> str: /// 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). + import 'dart:developer'; + import 'package:flutter/widgets.dart'; import 'package:flutter_gen/gen_l10n/app_localizations.dart'; + import 'package:logging/logging.dart'; String getTranslation(String value, BuildContext context) { switch (value) {''' @@ -127,8 +130,10 @@ def cleanup_name(text: str) -> str: out += ''' default: - throw FormatException('Could not translate the server string $value'); - }}''' + log('Could not translate the server string $value', level: Level.WARNING.value); + return value; + } + }''' f.write(out) self.stdout.write(self.style.SUCCESS('Wrote content to wger/i18n.dart'))