From 1458ac339888b7b3270f4df55fbf973821103654 Mon Sep 17 00:00:00 2001 From: Marius Tomaschewski Date: Mon, 27 Nov 2006 15:19:48 +0000 Subject: [PATCH] - Added translations marks to hal, url and mutex exceptions (#23771) --- package/libzypp.changes | 6 ++++++ zypp/Url.cc | 14 +++++++------ zypp/target/hal/HalContext.cc | 34 ++++++++++++++++++++----------- zypp/target/hal/HalException.h | 11 +++++++---- zypp/thread/Mutex.cc | 13 ++++++------ zypp/url/UrlBase.cc | 45 +++++++++++++++++++++--------------------- zypp/url/UrlUtils.cc | 10 ++++++---- 7 files changed, 80 insertions(+), 53 deletions(-) diff --git a/package/libzypp.changes b/package/libzypp.changes index 6bd21b1..120768c 100644 --- a/package/libzypp.changes +++ b/package/libzypp.changes @@ -1,4 +1,10 @@ ------------------------------------------------------------------- +Mon Nov 27 16:17:07 CET 2006 - mt@suse.de + +- Added translations marks to hal, url and mutex exceptions (#23771) +- revision 4680 + +------------------------------------------------------------------- Wed Nov 22 19:24:57 CET 2006 - dmacvicar@suse.de - don't make libzypp-devel depend on sqlite-devel as diff --git a/zypp/Url.cc b/zypp/Url.cc index fff6e8c..7903909 100644 --- a/zypp/Url.cc +++ b/zypp/Url.cc @@ -10,6 +10,7 @@ * \file zypp/Url.cc */ #include +#include #include #include @@ -106,7 +107,7 @@ namespace zypp else { ZYPP_THROW(url::UrlNotSupportedException( - "Invalid LDAP URL query string" + _("Invalid LDAP URL query string") )); } return pmap; @@ -145,7 +146,8 @@ namespace zypp if( !found) { ZYPP_THROW(url::UrlNotSupportedException( - "Invalid LDAP URL query parameter '" + p->first + "'" + str::form(_("Invalid LDAP URL query parameter '%s'"), + p->first.c_str()) )); } } @@ -285,7 +287,7 @@ namespace zypp if( !m_impl) { ZYPP_THROW(url::UrlException( - "Unable to clone Url object" + _("Unable to clone Url object") )); } } @@ -298,7 +300,7 @@ namespace zypp if( !m_impl) { ZYPP_THROW(url::UrlException( - "Invalid empty Url reference" + _("Invalid empty Url object reference") )); } } @@ -311,7 +313,7 @@ namespace zypp if( !m_impl) { ZYPP_THROW(url::UrlParsingException( - "Unable to parse Url components" + _("Unable to parse Url components") )); } } @@ -325,7 +327,7 @@ namespace zypp if( !url) { ZYPP_THROW(url::UrlParsingException( - "Unable to parse Url components" + _("Unable to parse Url components") )); } m_impl = url; diff --git a/zypp/target/hal/HalContext.cc b/zypp/target/hal/HalContext.cc index dab8bb4..87f12bc 100644 --- a/zypp/target/hal/HalContext.cc +++ b/zypp/target/hal/HalContext.cc @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include @@ -70,11 +72,15 @@ namespace zypp return dbus_error_is_set(&error); } - inline HalException halException() const + inline HalException halException(const std::string &msg = std::string()) const { - if( error.name != NULL && error.message != NULL) { + if( isSet() && error.name != NULL && error.message != NULL) { return HalException(error.name, error.message); - } else { + } + else if( !msg.empty()) { + return HalException(msg); + } + else { return HalException(); } } @@ -87,7 +93,7 @@ namespace zypp { if( !h) { - ZYPP_THROW(HalException("HalContext not connected")); + ZYPP_THROW(HalException(_("HalContext not connected"))); } } @@ -97,7 +103,7 @@ namespace zypp { if( !d) { - ZYPP_THROW(HalException("HalDrive not initialized")); + ZYPP_THROW(HalException(_("HalDrive not initialized"))); } } @@ -107,7 +113,7 @@ namespace zypp { if( !v) { - ZYPP_THROW(HalException("HalVolume not initialized")); + ZYPP_THROW(HalException(_("HalVolume not initialized"))); } } @@ -121,6 +127,8 @@ namespace zypp { if(!e_name.empty() && !e_msg.empty()) return str << msg() << ": " << e_msg << " (" << e_name << ")"; + else if(!e_msg.empty()) + return str << msg() << ": " << e_msg; else return str << msg(); } @@ -196,7 +204,9 @@ namespace zypp else conn = dbus_bus_get(DBUS_BUS_SYSTEM, &err.error); if( !conn) { - ZYPP_THROW(err.halException()); + ZYPP_THROW(err.halException( + _("Unable to create dbus connection") + )); } if( monitorable) @@ -211,7 +221,7 @@ namespace zypp conn = NULL; ZYPP_THROW(HalException( - "libhal_ctx_new: Can't create libhal context" + _("libhal_ctx_new: Can't create libhal context") )); } @@ -226,7 +236,7 @@ namespace zypp conn = NULL; ZYPP_THROW(HalException( - "libhal_set_dbus_connection: Can't set dbus connection" + _("libhal_set_dbus_connection: Can't set dbus connection") )); } @@ -240,7 +250,9 @@ namespace zypp dbus_connection_unref(conn); conn = NULL; - ZYPP_THROW(err.halException()); + ZYPP_THROW(err.halException( + _("Unable to initalize HAL context -- hald not running?") + )); } } @@ -828,7 +840,7 @@ namespace zypp #if 0 if( libhal_drive_get_type(d_impl->drv) != LIBHAL_DRIVE_TYPE_CDROM) - ZYPP_THROW(HalException("Not a CDROM drive")); + ZYPP_THROW(HalException(_("Not a CDROM drive"))); /* ** FIXME: we use property keys matching diff --git a/zypp/target/hal/HalException.h b/zypp/target/hal/HalException.h index 993f4f9..3ea3189 100644 --- a/zypp/target/hal/HalException.h +++ b/zypp/target/hal/HalException.h @@ -14,7 +14,8 @@ #define ZYPP_TARGET_HAL_HALEXCEPTION_H #include -#include +#include +#include ////////////////////////////////////////////////////////////////////// @@ -42,7 +43,7 @@ namespace zypp * Use \ref ZYPP_THROW to throw exceptions. */ HalException() - : zypp::Exception("Hal Exception") + : zypp::Exception(_("Hal Exception")) {} /** Constructor taking complete hal error message. @@ -51,14 +52,16 @@ namespace zypp * Use \ref ZYPP_THROW to throw exceptions. */ HalException(const std::string &msg_r) - : zypp::Exception("Hal Exception: " + msg_r) + : zypp::Exception(_("Hal Exception")) + , e_name() + , e_msg(msg_r) {} /** Constructor taking HAL (DBUS) error message components. * Use \ref ZYPP_THROW to throw exceptions. */ HalException(const std::string &err_name, const std::string &err_msg) - : zypp::Exception("Hal Exception") + : zypp::Exception(_("Hal Exception")) , e_name(err_name) , e_msg(err_msg) {} diff --git a/zypp/thread/Mutex.cc b/zypp/thread/Mutex.cc index c9c0560..df2b481 100644 --- a/zypp/thread/Mutex.cc +++ b/zypp/thread/Mutex.cc @@ -10,6 +10,7 @@ */ #include #include +#include ////////////////////////////////////////////////////////////////////// @@ -29,21 +30,21 @@ namespace zypp if( ret != 0) { ZYPP_THROW_ERRNO_MSG(zypp::thread::MutexException, - "Can't initialize mutex attributes"); + _("Can't initialize mutex attributes")); } ret = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); if( ret != 0) { ZYPP_THROW_ERRNO_MSG(MutexException, - "Can't set recursive mutex attribute"); + _("Can't set recursive mutex attribute")); } ret = pthread_mutex_init(&m_mutex, &attr); if( ret != 0) { ZYPP_THROW_ERRNO_MSG(MutexException, - "Can't initialize recursive mutex"); + _("Can't initialize recursive mutex")); } } @@ -61,7 +62,7 @@ namespace zypp else { ZYPP_THROW_ERRNO_MSG(MutexException, - "Can't destroy mutex owned by another thread"); + _("Can't destroy mutex owned by another thread")); } */ } @@ -73,7 +74,7 @@ namespace zypp if( pthread_mutex_lock(&m_mutex) != 0) { ZYPP_THROW_ERRNO_MSG(MutexException, - "Can't acquire the mutex lock"); + _("Can't acquire the mutex lock")); } } @@ -83,7 +84,7 @@ namespace zypp if( pthread_mutex_unlock(&m_mutex) != 0) { ZYPP_THROW_ERRNO_MSG(MutexException, - "Can't release the mutex lock"); + _("Can't release the mutex lock")); } } diff --git a/zypp/url/UrlBase.cc b/zypp/url/UrlBase.cc index eda0bde..887b3f3 100644 --- a/zypp/url/UrlBase.cc +++ b/zypp/url/UrlBase.cc @@ -11,7 +11,8 @@ */ #include #include - +#include + #include #include #include @@ -147,7 +148,7 @@ namespace zypp if( regx.empty() || regx == "^$") { ZYPP_THROW(UrlNotAllowedException( - std::string("Url scheme does not allow a " + name) + str::form(_("Url scheme does not allow a %s"), name.c_str()) )); } else @@ -166,14 +167,14 @@ namespace zypp if( show) { ZYPP_THROW(UrlBadComponentException( - std::string("Invalid " + name + " component '" + - data + "'") + str::form(_("Invalid %s component '%s'"), + name.c_str(), data.c_str()) )); } else { ZYPP_THROW(UrlBadComponentException( - std::string("Invalid " + name + " component") + str::form(_("Invalid %s component"), name.c_str()) )); } } @@ -720,7 +721,7 @@ namespace zypp config("vsep_pathparam").empty()) { ZYPP_THROW(UrlNotSupportedException( - "Path parameter parsing not supported for this URL" + _("Path parameter parsing not supported for this URL") )); } zypp::url::ParamMap pmap; @@ -775,7 +776,7 @@ namespace zypp config("vsep_querystr").empty()) { ZYPP_THROW(UrlNotSupportedException( - "Query string parsing not supported for this URL" + _("Query string parsing not supported for this URL") )); } zypp::url::ParamMap pmap; @@ -813,13 +814,13 @@ namespace zypp if( scheme.empty()) { ZYPP_THROW(UrlBadComponentException( - std::string("Url scheme is a required component") + _("Url scheme is a required component") )); } else { ZYPP_THROW(UrlBadComponentException( - std::string("Invalid Url scheme '" + scheme + "'") + str::form(_("Invalid Url scheme '%s'"), scheme.c_str()) )); } } @@ -850,7 +851,7 @@ namespace zypp else { ZYPP_THROW(UrlParsingException( - "Unable to parse Url authority" + _("Unable to parse Url authority") )); } } @@ -938,7 +939,7 @@ namespace zypp if( config("with_authority") != "y") { ZYPP_THROW(UrlNotAllowedException( - std::string("Url scheme does not allow a username") + _("Url scheme does not allow a username") )); } @@ -972,7 +973,7 @@ namespace zypp if( config("with_authority") != "y") { ZYPP_THROW(UrlNotAllowedException( - std::string("Url scheme does not allow a password") + _("Url scheme does not allow a password") )); } @@ -1001,7 +1002,7 @@ namespace zypp if(config("require_host") == "m") { ZYPP_THROW(UrlNotAllowedException( - std::string("Url scheme requires a host") + _("Url scheme requires a host component") )); } m_data->host = host; @@ -1011,7 +1012,7 @@ namespace zypp if( config("with_authority") != "y") { ZYPP_THROW(UrlNotAllowedException( - std::string("Url scheme does not allow a host") + _("Url scheme does not allow a host component") )); } @@ -1038,7 +1039,7 @@ namespace zypp else { ZYPP_THROW(UrlBadComponentException( - std::string("Invalid host argument '" + host + "'") + str::form(_("Invalid host component '%s'"), host.c_str()) )); } } @@ -1059,7 +1060,7 @@ namespace zypp config("with_port") != "y") { ZYPP_THROW(UrlNotAllowedException( - std::string("Url scheme does not allow a port") + _("Url scheme does not allow a port") )); } @@ -1070,7 +1071,7 @@ namespace zypp else { ZYPP_THROW(UrlBadComponentException( - std::string("Invalid host argument '" + port + "'") + str::form(_("Invalid port component '%s'"), port.c_str()) )); } } @@ -1087,7 +1088,7 @@ namespace zypp if(config("require_pathname") == "m") { ZYPP_THROW(UrlNotAllowedException( - std::string("Url scheme requires path name") + _("Url scheme requires path name") )); } m_data->pathname = path; @@ -1108,7 +1109,7 @@ namespace zypp str::toLower(path.substr(0, 3)) == "%2f"))) { ZYPP_THROW(UrlNotAllowedException( - std::string("Relative path not allowed if authority exists") + _("Relative path not allowed if authority exists") )); } } @@ -1122,7 +1123,7 @@ namespace zypp if(path.at(0) != '/') { ZYPP_THROW(UrlNotAllowedException( - std::string("Relative path not allowed if authority exists") + _("Relative path not allowed if authority exists") )); } } @@ -1175,7 +1176,7 @@ namespace zypp config("vsep_pathparam").empty()) { ZYPP_THROW(UrlNotSupportedException( - "Path Parameter parsing not supported for this URL" + _("Path Parameter parsing not supported for this URL") )); } setPathParams( @@ -1220,7 +1221,7 @@ namespace zypp config("vsep_querystr").empty()) { ZYPP_THROW(UrlNotSupportedException( - "Query string parsing not supported for this URL" + _("Query string parsing not supported for this URL") )); } setQueryString( diff --git a/zypp/url/UrlUtils.cc b/zypp/url/UrlUtils.cc index 5b8da73..ca83df6 100644 --- a/zypp/url/UrlUtils.cc +++ b/zypp/url/UrlUtils.cc @@ -9,6 +9,8 @@ /** * \file zypp/url/UrlUtils.cc */ +#include +#include #include #include // strtol @@ -106,7 +108,7 @@ namespace zypp if( !allowNUL) { ZYPP_THROW(UrlDecodingException( - "Encoded string contains a NUL byte" + _("Encoded string contains a NUL byte") )); } default: @@ -168,7 +170,7 @@ namespace zypp if( psep.empty()) { ZYPP_THROW(UrlNotSupportedException( - "Invalid split separator character." + _("Invalid parameter array split separator character") )); } @@ -208,7 +210,7 @@ namespace zypp if( psep.empty() || vsep.empty()) { ZYPP_THROW(UrlNotSupportedException( - "Invalid split separator character." + _("Invalid parameter map split separator character") )); } @@ -278,7 +280,7 @@ namespace zypp if( psep.empty() || vsep.empty()) { ZYPP_THROW(UrlNotSupportedException( - "Invalid join separator character." + _("Invalid parameter array join separator character") )); } -- 2.7.4