1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix(i18n): Divide getting and translating Toxme error message

This commit is contained in:
Diadlo 2016-05-10 23:28:59 +03:00
parent 5cb271b0c0
commit 98a1f23bfb
No known key found for this signature in database
GPG Key ID: 5AF9F2E29107C727
2 changed files with 53 additions and 12 deletions

View File

@ -288,21 +288,65 @@ Toxme::ExecCode Toxme::deleteAddress(QString server, ToxId id)
return extractError(response);
}
/**
* @brief Return string of the corresponding error code
* @param errorCode Code to get error message
* @return Source error message
*/
QString Toxme::getErrorMessage(int errorCode)
{
switch (errorCode) {
case IncorrectResponse:
return QObject::tr("Incorrect response");
return "Incorrect response";
case NoPassword:
return QObject::tr("No password in response");
return "No password in response";
case ServerError:
return "Server doesn't support Toxme";
case -1:
return "You must send POST requests to /api";
case -2:
return "Problem with HTTPS connection";
case -3:
return "I was unable to read your encrypted payload";
case -4:
return "You're making too many requests. Wait an hour and try again";
case -25:
return "This name is already in use";
case -26:
return "This Tox ID is already registered under another name";
case -27:
return "Please don't use a space in your name";
case -28:
return "Password incorrect";
case -29:
return "You can't use this name";
case -30:
return "Name not found";
case -31:
return "Tox ID not sent";
case -41:
return "Lookup failed because the server replied with invalid data";
case -42:
return "That user does not exist";
case -43:
return "Internal lookup error. Please file a bug";
default:
return QString("Unknown error (%1)").arg(errorCode);
}
}
/**
* @brief Return translated error message
* @param errorCode Code to translate
* @return Translated Toxme error message
*/
QString Toxme::translateErrorMessage(int errorCode)
{
switch (errorCode) {
case ServerError:
return QObject::tr("Server doesn't support Toxme");
case -1:
return QObject::tr("You must send POST requests to /api");
case -2:
return QObject::tr("Please try again using a HTTPS connection");
case -3:
return QObject::tr("I was unable to read your encrypted payload");
return QObject::tr("Problem with HTTPS connection");
case -4:
return QObject::tr("You're making too many requests. Wait an hour and try again");
case -25:
@ -319,13 +363,9 @@ QString Toxme::getErrorMessage(int errorCode)
return QObject::tr("Name not found");
case -31:
return QObject::tr("Tox ID not sent");
case -41:
return QObject::tr("Lookup failed because the server replied with invalid data");
case -42:
return QObject::tr("That user does not exist");
case -43:
return QObject::tr("Internal lookup error. Please file a bug");
default:
return QObject::tr("Unknown error (%1)").arg(errorCode);
return QObject::tr("Internal ToxMe error");
}
}

View File

@ -57,6 +57,7 @@ public:
static ExecCode deleteAddress(QString server, ToxId id);
/// Return string of the corresponding error code
static QString getErrorMessage(int errorCode);
static QString translateErrorMessage(int errorCode);
private:
Toxme()=delete;