diff --git a/src/TransportCurl.cpp b/src/TransportCurl.cpp index 65fd2945f..f28f562f9 100644 --- a/src/TransportCurl.cpp +++ b/src/TransportCurl.cpp @@ -25,8 +25,11 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + #include #include +#include #include //////////////////////////////////////////////////////////////////////////////// @@ -39,7 +42,7 @@ TransportCurl::TransportCurl(const Uri& uri) : Transport(uri) void TransportCurl::send(const std::string& source) { if (uri.host == "") - throw std::string ("when using the 'curl' protocol, the uri must contain a hostname."); + throw std::string (STRING_TRANSPORT_CURL_URI); if (uri.user != "") { @@ -53,10 +56,10 @@ void TransportCurl::send(const std::string& source) pos = source.find("{"); if (pos == std::string::npos) - throw std::string ("When using the 'curl' protocol, wildcards are not supported."); + throw std::string (STRING_TRANSPORT_CURL_WILDCD); if (!uri.is_directory()) - throw std::string ("The uri '") + uri.path + "' does not appear to be a directory."; + throw format (STRING_TRANSPORT_URI_NODIR, uri.path); arguments.push_back ("-T"); arguments.push_back ("\"" + source + "\""); @@ -81,9 +84,9 @@ void TransportCurl::send(const std::string& source) if (result) { if (result == 127) // command not found - throw std::string ("Could not run curl. Is it installed, and available in $PATH?"); + throw std::string (STRING_TRANSPORT_CURL_NORUN); else - throw std::string ("Curl failed, see output above."); + throw std::string (STRING_TRANSPORT_CURL_FAIL); } } @@ -91,7 +94,7 @@ void TransportCurl::send(const std::string& source) void TransportCurl::recv(std::string target) { if (uri.host == "") - throw std::string ("when using the 'curl' protocol, the uri must contain a hostname."); + throw std::string (STRING_TRANSPORT_CURL_URI); if (uri.user != "") { @@ -106,10 +109,10 @@ void TransportCurl::recv(std::string target) pos = uri.path.find("{"); if (pos == std::string::npos) - throw std::string ("When using the 'curl' protocol, wildcards are not supported."); + throw std::string (STRING_TRANSPORT_CURL_WILDCD); if (!is_directory(target)) - throw std::string ("The uri '") + target + "' does not appear to be a directory."; + throw format (STRING_TRANSPORT_URI_NODIR, target); std::string toSplit; std::string suffix; @@ -147,9 +150,9 @@ void TransportCurl::recv(std::string target) if (result) { if (result == 127) // command not found - throw std::string ("Could not run curl. Is it installed, and available in $PATH?"); + throw std::string (STRING_TRANSPORT_CURL_NORUN); else - throw std::string ("Curl failed, see output above."); + throw std::string (STRING_TRANSPORT_CURL_FAIL); } } diff --git a/src/TransportRSYNC.cpp b/src/TransportRSYNC.cpp index 1777c1f52..0a28c2f5a 100644 --- a/src/TransportRSYNC.cpp +++ b/src/TransportRSYNC.cpp @@ -25,6 +25,10 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + +#include +#include #include //////////////////////////////////////////////////////////////////////////////// @@ -37,12 +41,12 @@ TransportRSYNC::TransportRSYNC(const Uri& uri) : Transport(uri) void TransportRSYNC::send(const std::string& source) { if (uri.host == "") - throw std::string ("when using the 'rsync' protocol, the uri must contain a hostname."); + throw std::string (STRING_TRANSPORT_RSYNC_URI); // Is there more than one file to transfer? // Then path has to end with a '/' if (is_filelist(source) && !uri.is_directory()) - throw std::string ("The uri '") + uri.path + "' does not appear to be a directory."; + throw format (STRING_TRANSPORT_URI_NODIR, uri.path); // cmd line is: rsync [--port=PORT] source [user@]host::path if (uri.port != "") @@ -62,19 +66,19 @@ void TransportRSYNC::send(const std::string& source) } if (execute()) - throw std::string ("Could not run rsync. Is it installed, and available in $PATH?"); + throw std::string (STRING_TRANSPORT_RSYNC_NORUN); } //////////////////////////////////////////////////////////////////////////////// void TransportRSYNC::recv(std::string target) { if (uri.host == "") - throw std::string ("when using the 'rsync' protocol, the uri must contain a hostname."); + throw std::string (STRING_TRANSPORT_RSYNC_URI); // Is there more than one file to transfer? // Then target has to end with a '/' if (is_filelist(uri.path) && !is_directory(target)) - throw std::string ("The uri '") + target + "' does not appear to be a directory."; + throw format (STRING_TRANSPORT_URI_NODIR, target); // cmd line is: rsync [--port=PORT] [user@]host::path target if (uri.port != "") @@ -92,7 +96,7 @@ void TransportRSYNC::recv(std::string target) arguments.push_back (target); if (execute()) - throw std::string ("Could not run rsync. Is it installed, and available in $PATH?"); + throw std::string (STRING_TRANSPORT_RSYNC_NORUN); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/TransportSSH.cpp b/src/TransportSSH.cpp index 53815e303..2be951ad0 100644 --- a/src/TransportSSH.cpp +++ b/src/TransportSSH.cpp @@ -25,6 +25,10 @@ // //////////////////////////////////////////////////////////////////////////////// +#define L10N // Localization complete. + +#include +#include #include //////////////////////////////////////////////////////////////////////////////// @@ -37,12 +41,12 @@ TransportSSH::TransportSSH(const Uri& uri) : Transport(uri) void TransportSSH::send(const std::string& source) { if (uri.host == "") - throw std::string ("when using the 'ssh' protocol, the uri must contain a hostname."); + throw std::string (STRING_TRANSPORT_SSH_URI); // Is there more than one file to transfer? // Then path has to end with a '/' if (is_filelist(source) && !uri.is_directory()) - throw std::string ("The uri '") + uri.path + "' does not appear to be a directory."; + throw format (STRING_TRANSPORT_URI_NODIR, uri.path); // cmd line is: scp [-p port] [user@]host:path if (uri.port != "") @@ -63,19 +67,19 @@ void TransportSSH::send(const std::string& source) } if (execute()) - throw std::string ("Could not run scp. Is it installed, and available in $PATH?"); + throw std::string (STRING_TRANSPORT_SSH_NORUN); } //////////////////////////////////////////////////////////////////////////////// void TransportSSH::recv(std::string target) { if (uri.host == "") - throw std::string ("when using the 'ssh' protocol, the uri must contain a hostname."); + throw std::string (STRING_TRANSPORT_SSH_URI); // Is there more than one file to transfer? // Then target has to end with a '/' if (is_filelist(uri.path) && !is_directory(target)) - throw std::string ("The uri '") + target + "' does not appear to be a directory."; + throw format (STRING_TRANSPORT_URI_NODIR, target); // cmd line is: scp [-p port] [user@]host:path if (uri.port != "") @@ -96,7 +100,7 @@ void TransportSSH::recv(std::string target) arguments.push_back (target); if (execute()) - throw std::string ("Could not run scp. Is it installed, and available in $PATH?"); + throw std::string (STRING_TRANSPORT_SSH_NORUN); } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/en-US.h b/src/en-US.h index 4d87fc450..8a52aa11f 100644 --- a/src/en-US.h +++ b/src/en-US.h @@ -352,6 +352,18 @@ // A comma-separated list of commands is appended. #define STRING_TEXT_AMBIGUOUS "Ambiguous {1} '{2}' - could be either of " +// Transport +#define STRING_TRANSPORT_URI_NODIR "The uri '{1}' does not appear to be a directory." +#define STRING_TRANSPORT_CURL_URI "When using the 'curl' protocol, the uri must contain a hostname." +#define STRING_TRANSPORT_CURL_WILDCD "When using the 'curl' protocol, wildcards are not supported." +#define STRING_TRANSPORT_CURL_NORUN "Could not run curl. Is it installed, and available in $PATH?" +#define STRING_TRANSPORT_CURL_FAIL "Curl failed, see output above." +#define STRING_TRANSPORT_RSYNC_URI "When using the 'rsync' protocol, the uri must contain a hostname." +#define STRING_TRANSPORT_RSYNC_NORUN "Could not run rsync. Is it installed, and available in $PATH?" +#define STRING_TRANSPORT_SSH_URI "When using the 'ssh' protocol, the uri must contain a hostname." +#define STRING_TRANSPORT_SSH_NORUN "Could not run ssh. Is it installed, and available in $PATH?" + + // Uri #define STRING_URI_QUOTES "Could not parse uri '{1}', wrong usage of single quotes." #define STRING_URI_BAD_FORMAT "The uri '{1}' is not in the expected format."