actions-test/lib/backend/errors.dart
Jakob Meier 8fffafde47
Added translations using l10n
Translations are provided in *.arb* format.
Some keys have descriptions
(indicated by leading @-symbol).
Descriptions should not be copied into the translation itself.

Currently only English is supported (app_en.arb),
but German is planned.

Apparently weblate merged .arb support at some time,
so it would be nice to enable community translations at some point.
2023-03-29 15:14:27 +02:00

32 lines
840 B
Dart

import 'package:flutter_gen/gen_l10n/app_localizations.dart';
/*
* Tool to automatically generate english text from error
*/
String errorAsString(Map<String, dynamic> json, AppLocalizations trans) {
switch (json['data']) {
case 'notfound':
return trans.errorNotFound;
case 'wrongstate':
return trans.errorDataIncomplete;
case 'data':
return trans.errorDataInvalid;
case 'roomAdmin':
case 'right':
return trans.errorPermissions;
case 'server':
return trans.errorServer;
case 'closed':
return trans.errorUnreachable;
case 'auth':
return trans.errorAuth;
case 'ota':
return trans.errorInvalidOTA;
case 'existence':
return trans.errorUsernameUnavailable;
case 'config':
return trans.errorServerLimit;
}
return trans.errorUnknown;
}