mirror of
https://github.com/wger-project/flutter.git
synced 2026-02-18 00:17:48 +01:00
Merge pull request #823 from wger-project/fix/translation-handling
Better handling of dynamic translations
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user