Skip to content

Commit

Permalink
Added Translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Teifun2 committed Dec 6, 2020
1 parent cfe7036 commit 6122aa7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
14 changes: 8 additions & 6 deletions assets/i18n/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
10 changes: 6 additions & 4 deletions assets/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
17 changes: 10 additions & 7 deletions lib/src/services/authentication_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 =
Expand All @@ -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,
}));
}
}

Expand Down Expand Up @@ -122,7 +126,6 @@ class AuthenticationProvider {
debugPrint(translate('login.errors.failed_remove_remote'));
}

//TODO Delete Appkey Serverside
currentAppAuthentication = null;
await _secureStorage.delete(key: _appAuthenticationKey);
}
Expand Down

0 comments on commit 6122aa7

Please sign in to comment.