From 6122aa76e00988fed688f3ae17b8ac61821be459 Mon Sep 17 00:00:00 2001 From: Linard Schwendener Date: Sun, 6 Dec 2020 16:24:47 +0100 Subject: [PATCH] Added Translations --- assets/i18n/de.json | 14 ++++++++------ assets/i18n/en.json | 10 ++++++---- lib/src/services/authentication_provider.dart | 17 ++++++++++------- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/assets/i18n/de.json b/assets/i18n/de.json index c3f61600..7275d570 100644 --- a/assets/i18n/de.json +++ b/assets/i18n/de.json @@ -21,12 +21,14 @@ }, "button": "Anmelden", "errors": { - "not_reachable": "Cannot reach: {server_url} \n {error_msg}", - "interrupted": "Login Process was interrupted!", - "window_error": "Could not launch the authentication window.", - "communication_failed": "Could not communicate with the server. Check if the url is correct.", - "authentication_not_found": "No authentication found in Storage", - "failed_remove_remote": "Failed to remove remote apppassword!" + "not_reachable": "Server konnte nicht erreicht werden: {server_url} \n {error_msg}", + "request_failed": "AppPassword Anfrage fehlgeschlagen:\n {error_msg}", + "parse_failed": "Konnte die AppPassword Antwort nicht lesen!\n {error_msg}", + "parse_missing": "Das AppPassword fehlt in der response!\n {error_msg}", + "auth_failed": "Benutzername oder Passwort ist incorrect!", + "authentication_not_found": "Es wurde keine gespeicherte Authentifizierung gefunden.", + "failed_remove_remote": "Das entfernen des appPasswortes auf dem server ist fehlgeschlagen!", + "failure": "Der Login Prozess konnte nicht erfolgreich beendet werden. \n {status_code}\n {status_message}" } }, "categories": { diff --git a/assets/i18n/en.json b/assets/i18n/en.json index 846a5f7d..b353ef2e 100644 --- a/assets/i18n/en.json +++ b/assets/i18n/en.json @@ -22,11 +22,13 @@ "button": "Login", "errors": { "not_reachable": "Cannot reach: {server_url} \n {error_msg}", - "interrupted": "Login Process was interrupted!", - "window_error": "Could not launch the authentication window.", - "communication_failed": "Could not communicate with the server. Check if the url is correct.", + "request_failed": "AppPassword request failed:\n {error_msg}", + "parse_failed": "Cannot parse the appPassword response!\n {error_msg}", + "parse_missing": "Cannot find appPassword in response!\n {error_msg}", + "auth_failed": "Username and / or Password is incorrect!", "authentication_not_found": "No authentication found in Storage", - "failed_remove_remote": "Failed to remove remote apppassword!" + "failed_remove_remote": "Failed to remove remote apppassword!", + "failure": "Login Process could not finish properly.\n {status_code}\n {status_message}" } }, "categories": { diff --git a/lib/src/services/authentication_provider.dart b/lib/src/services/authentication_provider.dart index 67d88a02..ae81c641 100644 --- a/lib/src/services/authentication_provider.dart +++ b/lib/src/services/authentication_provider.dart @@ -42,9 +42,10 @@ class AuthenticationProvider { ); } on dio.DioError catch (e) { if (e.message.contains("SocketException")) { - throw ("SocketException: The URL is wrong or the server is not reachable!\n $e"); + throw (translate("login.errors.not_reachable", + args: {"server_url": serverUrl, "error_msg": e})); } - throw ("AppPassword request failed:\n $e"); + throw (translate("login.errors.request_failed", args: {"error_msg": e})); } if (response.statusCode == 200) { @@ -55,9 +56,9 @@ class AuthenticationProvider { .first .text; } on XmlParserException catch (e) { - throw ('Cannot parse the appPassword response!\n $e'); + throw (translate("login.errors.parse_failed", args: {"error_msg": e})); } on StateError catch (e) { - throw ('Cannot find appPassword in response!\n $e'); + throw (translate("login.errors.parse_missing", args: {"error_msg": e})); } String basicAuth = @@ -69,9 +70,12 @@ class AuthenticationProvider { basicAuth: basicAuth, ); } else if (response.statusCode == 401) { - throw ('Username and / or Password is incorrect!'); + throw (translate("login.errors.auth_failed")); } else { - throw ('Login Process could not finish properly.\n ${response.statusCode}\n ${response.statusMessage}'); + throw (translate("login.errors.failure", args: { + "status_code": response.statusCode, + "status_message": response.statusMessage, + })); } } @@ -122,7 +126,6 @@ class AuthenticationProvider { debugPrint(translate('login.errors.failed_remove_remote')); } - //TODO Delete Appkey Serverside currentAppAuthentication = null; await _secureStorage.delete(key: _appAuthenticationKey); }