Merge pull request #823 from wger-project/fix/translation-handling

Better handling of dynamic translations
This commit is contained in:
Roland Geider
2025-05-16 15:20:56 +02:00
committed by GitHub

View File

@@ -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;
}
}