Skip to content

Commit c2608af

Browse files
committed
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.
1 parent cc76bae commit c2608af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/helpers/i18n.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
/// This code is autogenerated in the backend repo in extract-i18n.py do not edit!
2-
library;
32
43
/// Translate dynamic strings that are returned from the server
54
/// These strings such as categories or equipment are returned by the server
65
/// in English and need to be translated here in the application (there are
76
/// probably better ways to do this, but that's the way it is right now).
87
98
import 'package:flutter/widgets.dart';
9+
import 'package:logging/logging.dart';
1010
import 'package:wger/l10n/generated/app_localizations.dart';
1111

1212
String getTranslation(String value, BuildContext context) {
13+
final logger = Logger('getTranslation');
14+
1315
switch (value) {
1416
case 'Abs':
1517
return AppLocalizations.of(context).abs;
@@ -129,6 +131,7 @@ String getTranslation(String value, BuildContext context) {
129131
return AppLocalizations.of(context).none__bodyweight_exercise_;
130132

131133
default:
132-
throw FormatException('Could not translate the server string $value');
134+
logger.warning('Could not translate the server string $value');
135+
return value;
133136
}
134137
}

0 commit comments

Comments
 (0)