From c2608af5697d02d8194a762ad9a1f63302fe2dd2 Mon Sep 17 00:00:00 2001 From: Roland Geider Date: Wed, 14 May 2025 17:14:34 +0200 Subject: [PATCH] Don't throw an exception for untranslated strings These are "dynamic" translations that come from the server. If they are not known locally, we should just show them to the user as-is. --- lib/helpers/i18n.dart | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/helpers/i18n.dart b/lib/helpers/i18n.dart index 1906ccca..8a270686 100644 --- a/lib/helpers/i18n.dart +++ b/lib/helpers/i18n.dart @@ -1,5 +1,4 @@ /// This code is autogenerated in the backend repo in extract-i18n.py do not edit! -library; /// Translate dynamic strings that are returned from the server /// These strings such as categories or equipment are returned by the server @@ -7,9 +6,12 @@ library; /// probably better ways to do this, but that's the way it is right now). import 'package:flutter/widgets.dart'; +import 'package:logging/logging.dart'; import 'package:wger/l10n/generated/app_localizations.dart'; String getTranslation(String value, BuildContext context) { + final logger = Logger('getTranslation'); + switch (value) { case 'Abs': return AppLocalizations.of(context).abs; @@ -129,6 +131,7 @@ String getTranslation(String value, BuildContext context) { return AppLocalizations.of(context).none__bodyweight_exercise_; default: - throw FormatException('Could not translate the server string $value'); + logger.warning('Could not translate the server string $value'); + return value; } }