mark more translatable messages

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This change marks for translation some more messages.
It adds a few new ones, too, e.g., replacing "domain" with
_("failed to parse domain description") in two places.

Likewise, there are some like this:

-            virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+            virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));

The two new grep invocations in Makefile.maint handle two situations:
First, when the entire statement is on a single line (ends in ";").
The second grep (with -A1) is to get the diagnostics that appear
on the line following the function name.  Hence where the first line
ends in ",".  With checks like this, it's nice if you can assume no
trailing blanks in the code base.  IMHO, that would be a nice change
to make soon, but it's more invasive.

	Enable more checks for unmarked messages; fix violators.
	* Makefile.maint (sc_unmarked_diagnostics): Check for more functions.
	* src/conf.c (virConfParseValue): Remove trailing space in diagnostic.
	* src/libvirt.c (do_open, virDomainMigrate): Mark diagnostics.
	* src/xend_internal.c (do_connect, xenDaemonDomainDumpXMLByID): Likewise.
	(xenDaemonDomainDumpXMLByName, xenDaemonCreateLinux): Likewise.
	(xenDaemonDomainMigratePerform, xenDaemonDomainDefineXML): Likewise.
	* src/xml.c (virXPathString, virXPathNumber, virXPathLong): Likewise.
	(virXPathBoolean, virXPathNode, virXPathNodeSet): Likewise.
	(virDomainParseXMLOSDescHVM): Likewise.
	* src/xmlrpc.c (xmlRpcValueNew): Likewise.
	(xmlRpcValueUnmarshalDictElement): Likewise.

Signed-off-by: Jim Meyering <meyering@xxxxxxxxxx>
---
 Makefile.maint      |   10 +++++++++-
 src/conf.c          |    4 ++--
 src/libvirt.c       |    6 +++---
 src/xend_internal.c |   40 ++++++++++++++++++++++++----------------
 src/xml.c           |   24 +++++++++++++-----------
 src/xmlrpc.c        |    4 ++--
 6 files changed, 53 insertions(+), 35 deletions(-)

diff --git a/Makefile.maint b/Makefile.maint
index 0336f13..356ca73 100644
--- a/Makefile.maint
+++ b/Makefile.maint
@@ -287,14 +287,22 @@ sc_two_space_separator_in_usage:
 	    echo "$(ME): an option and its description"; \
 		1>&2; exit 1; } || :

+err_func_re = \
+(DISABLE_fprintf|(xmlRpc|vir(Xend|XML|Hash|Conf|Test|LibConn))Error)
+
 # Look for diagnostics that aren't marked for translation.
 # This won't find any for which error's format string is on a separate line.
 sc_unmarked_diagnostics:
 	@grep -nE							\
-	    '\<error \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT))	\
+	    '\<(vshError|error) \([^"]*"[^"]*[a-z]{3}' $$($(CVS_LIST_EXCEPT))	\
 	  | grep -v '_''(' &&						\
 	  { echo '$(ME): found unmarked diagnostic(s)' 1>&2;		\
 	    exit 1; } || :
+	@{ grep     -nE '\<$(err_func_re) *\(.*;$$' $$($(CVS_LIST_EXCEPT));   \
+	   grep -A1 -nE '\<$(err_func_re) *\(.*,$$' $$($(CVS_LIST_EXCEPT)); } \
+	  | grep '[	 ]"' &&						\
+	  { echo '$(ME): found unmarked diagnostic(s)' 1>&2;		\
+	    exit 1; } || :

 # Avoid useless parentheses like those in this example:
 # #if defined (SYMBOL) || defined (SYM2)
diff --git a/src/conf.c b/src/conf.c
index 8b3aae5..d4e5227 100644
--- a/src/conf.c
+++ b/src/conf.c
@@ -1,7 +1,7 @@
 /**
  * conf.c: parser for a subset of the Python encoded Xen configuration files
  *
- * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006, 2007, 2008 Red Hat, Inc.
  *
  * See COPYING.LIB for the License of this software
  *
@@ -473,7 +473,7 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
 	    NEXT;
 	} else {
 	    virConfError(NULL, VIR_ERR_CONF_SYNTAX,
-			 _("list is not closed with ] "), ctxt->line);
+			 _("list is not closed with ]"), ctxt->line);
 	    virConfFreeList(lst);
 	    return(NULL);
 	}
diff --git a/src/libvirt.c b/src/libvirt.c
index c19565f..8ab4cbd 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -2,7 +2,7 @@
  * libvirt.c: Main interfaces for the libvirt library to handle virtualization
  *           domains from a process running in domain 0
  *
- * Copyright (C) 2005,2006 Red Hat, Inc.
+ * Copyright (C) 2005,2006,2008 Red Hat, Inc.
  *
  * See COPYING.LIB for the License of this software
  *
@@ -562,7 +562,7 @@ do_open (const char *name,

     ret->name = strdup (name);
     if (!ret->name) {
-        virLibConnError (ret, VIR_ERR_NO_MEMORY, "allocating conn->name");
+        virLibConnError (ret, VIR_ERR_NO_MEMORY, _("allocating conn->name"));
         goto failed;
     }

@@ -1946,7 +1946,7 @@ virDomainMigrate (virDomainPtr domain,
     if (ret == -1) goto done;
     if (uri == NULL && uri_out == NULL) {
         virLibConnError (conn, VIR_ERR_INTERNAL_ERROR,
-                         "domainMigratePrepare did not set uri");
+                         _("domainMigratePrepare did not set uri"));
         goto done;
     }
     if (uri_out) uri = uri_out; /* Did domainMigratePrepare change URI? */
diff --git a/src/xend_internal.c b/src/xend_internal.c
index bbe5013..78691c9 100644
--- a/src/xend_internal.c
+++ b/src/xend_internal.c
@@ -217,7 +217,7 @@ do_connect(virConnectPtr xend)
     s = socket(priv->type, SOCK_STREAM, 0);
     if (s == -1) {
         virXendError(xend, VIR_ERR_INTERNAL_ERROR,
-                     "failed to create a socket");
+                     _("failed to create a socket"));
         return -1;
     }

@@ -240,7 +240,7 @@ do_connect(virConnectPtr xend)
 	 */
 	if ((getuid() == 0) || (xend->flags & VIR_CONNECT_RO)) {
 	    virXendError(xend, VIR_ERR_INTERNAL_ERROR,
-			 "failed to connect to xend");
+                     _("failed to connect to xend"));
         }
     }

@@ -2512,7 +2512,8 @@ xenDaemonDomainDumpXMLByID(virConnectPtr conn, int domid, int flags,
     root = sexpr_get(conn, "/xend/domain/%d?detail=1", domid);
     if (root == NULL) {
         virXendError (conn, VIR_ERR_XEN_CALL,
-                      "xenDaemonDomainDumpXMLByID failed to find this domain");
+                      _("xenDaemonDomainDumpXMLByID failed to"
+                        " find this domain"));
         return (NULL);
     }

@@ -2536,7 +2537,8 @@ xenDaemonDomainDumpXMLByName(virConnectPtr conn, const char *name, int flags,
     root = sexpr_get(conn, "/xend/domain/%s?detail=1", name);
     if (root == NULL) {
         virXendError (conn, VIR_ERR_XEN_CALL,
-                      "xenDaemonDomainDumpXMLByName failed to find this domain");
+                      _("xenDaemonDomainDumpXMLByName failed to"
+                        " find this domain"));
         return (NULL);
     }

@@ -3144,7 +3146,8 @@ xenDaemonCreateLinux(virConnectPtr conn, const char *xmlDesc,

     sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
     if ((sexpr == NULL) || (name == NULL)) {
-        virXendError(conn, VIR_ERR_XML_ERROR, "domain");
+        virXendError(conn, VIR_ERR_XML_ERROR,
+                     _("failed to parse domain description"));
         free(sexpr);
         free(name);

@@ -3323,7 +3326,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
     /* Xen doesn't support renaming domains during migration. */
     if (dname) {
         virXendError (conn, VIR_ERR_NO_SUPPORT,
-                      "xenDaemonDomainMigrate: Xen does not support renaming domains during migration");
+                      _("xenDaemonDomainMigrate: Xen does not support"
+                        " renaming domains during migration"));
         return -1;
     }

@@ -3332,7 +3336,8 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
      */
     if (bandwidth) {
         virXendError (conn, VIR_ERR_NO_SUPPORT,
-                      "xenDaemonDomainMigrate: Xen does not support bandwidth limits during migration");
+                      _("xenDaemonDomainMigrate: Xen does not support"
+                        " bandwidth limits during migration"));
         return -1;
     }

@@ -3343,7 +3348,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
     }
     if (flags != 0) {
         virXendError (conn, VIR_ERR_NO_SUPPORT,
-                      "xenDaemonDomainMigrate: unsupported flag");
+                      _("xenDaemonDomainMigrate: unsupported flag"));
         return -1;
     }

@@ -3356,24 +3361,26 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
         xmlURIPtr uriptr = xmlParseURI (uri);
         if (!uriptr) {
             virXendError (conn, VIR_ERR_INVALID_ARG,
-                          "xenDaemonDomainMigrate: invalid URI");
+                          _("xenDaemonDomainMigrate: invalid URI"));
             return -1;
         }
         if (uriptr->scheme && STRCASENEQ (uriptr->scheme, "xenmigr")) {
             virXendError (conn, VIR_ERR_INVALID_ARG,
-                          "xenDaemonDomainMigrate: only xenmigr:// migrations are supported by Xen");
+                          _("xenDaemonDomainMigrate: only xenmigr://"
+                            " migrations are supported by Xen"));
             xmlFreeURI (uriptr);
             return -1;
         }
         if (!uriptr->server) {
             virXendError (conn, VIR_ERR_INVALID_ARG,
-                          "xenDaemonDomainMigrate: a hostname must be specified in the URI");
+                          _("xenDaemonDomainMigrate: a hostname must be"
+                            " specified in the URI"));
             xmlFreeURI (uriptr);
             return -1;
         }
         hostname = strdup (uriptr->server);
         if (!hostname) {
-            virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+            virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
             xmlFreeURI (uriptr);
             return -1;
         }
@@ -3386,7 +3393,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,

         if (sscanf (p+1, "%d", &port_nr) != 1) {
             virXendError (conn, VIR_ERR_INVALID_ARG,
-                          "xenDaemonDomainMigrate: invalid port number");
+                          _("xenDaemonDomainMigrate: invalid port number"));
             return -1;
         }
         snprintf (port, sizeof port, "%d", port_nr);
@@ -3395,7 +3402,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
         n = p - uri; /* n = Length of hostname in bytes. */
         hostname = strdup (uri);
         if (!hostname) {
-            virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+            virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
             return -1;
         }
         hostname[n] = '\0';
@@ -3403,7 +3410,7 @@ xenDaemonDomainMigratePerform (virDomainPtr domain,
     else {                      /* "hostname" (or IP address) */
         hostname = strdup (uri);
         if (!hostname) {
-            virXendError (conn, VIR_ERR_NO_MEMORY, "strdup");
+            virXendError (conn, VIR_ERR_NO_MEMORY, _("strdup failed"));
             return -1;
         }
     }
@@ -3448,7 +3455,8 @@ virDomainPtr xenDaemonDomainDefineXML(virConnectPtr conn, const char *xmlDesc) {

     sexpr = virDomainParseXMLDesc(conn, xmlDesc, &name, priv->xendConfigVersion);
     if ((sexpr == NULL) || (name == NULL)) {
-        virXendError(conn, VIR_ERR_XML_ERROR, "domain");
+        virXendError(conn, VIR_ERR_XML_ERROR,
+                     _("failed to parse domain description"));
         free(sexpr);
         free(name);

diff --git a/src/xml.c b/src/xml.c
index bf1c2eb..b7ffe2a 100644
--- a/src/xml.c
+++ b/src/xml.c
@@ -1,7 +1,7 @@
 /*
  * xml.c: XML based interfaces for the libvir library
  *
- * Copyright (C) 2005, 2007 Red Hat, Inc.
+ * Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
  *
  * See COPYING.LIB for the License of this software
  *
@@ -473,7 +473,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)

     if ((ctxt == NULL) || (xpath == NULL)) {
         virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
-                    "Invalid parameter to virXPathString()", 0);
+                    _("Invalid parameter to virXPathString()"), 0);
         return (NULL);
     }
     obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -486,7 +486,7 @@ virXPathString(const char *xpath, xmlXPathContextPtr ctxt)
     ret = strdup((char *) obj->stringval);
     xmlXPathFreeObject(obj);
     if (ret == NULL) {
-        virXMLError(NULL, VIR_ERR_NO_MEMORY, "strdup", 0);
+        virXMLError(NULL, VIR_ERR_NO_MEMORY, _("strdup failed"), 0);
     }
     return (ret);
 }
@@ -509,7 +509,7 @@ virXPathNumber(const char *xpath, xmlXPathContextPtr ctxt, double *value)

     if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
         virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
-                    "Invalid parameter to virXPathNumber()", 0);
+                    _("Invalid parameter to virXPathNumber()"), 0);
         return (-1);
     }
     obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -544,7 +544,7 @@ virXPathLong(const char *xpath, xmlXPathContextPtr ctxt, long *value)

     if ((ctxt == NULL) || (xpath == NULL) || (value == NULL)) {
         virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
-                    "Invalid parameter to virXPathNumber()", 0);
+                    _("Invalid parameter to virXPathNumber()"), 0);
         return (-1);
     }
     obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -590,7 +590,7 @@ virXPathBoolean(const char *xpath, xmlXPathContextPtr ctxt)

     if ((ctxt == NULL) || (xpath == NULL)) {
         virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
-                    "Invalid parameter to virXPathBoolean()", 0);
+                    _("Invalid parameter to virXPathBoolean()"), 0);
         return (-1);
     }
     obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -623,7 +623,7 @@ virXPathNode(const char *xpath, xmlXPathContextPtr ctxt)

     if ((ctxt == NULL) || (xpath == NULL)) {
         virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
-                    "Invalid parameter to virXPathNode()", 0);
+                    _("Invalid parameter to virXPathNode()"), 0);
         return (NULL);
     }
     obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -659,7 +659,7 @@ virXPathNodeSet(const char *xpath, xmlXPathContextPtr ctxt,

     if ((ctxt == NULL) || (xpath == NULL)) {
         virXMLError(NULL, VIR_ERR_INTERNAL_ERROR,
-                    "Invalid parameter to virXPathNodeSet()", 0);
+                    _("Invalid parameter to virXPathNodeSet()"), 0);
         return (-1);
     }
     obj = xmlXPathEval(BAD_CAST xpath, ctxt);
@@ -882,7 +882,7 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
                 if (nbootorder ==
                     ((sizeof(bootorder) / sizeof(bootorder[0])) - 1)) {
                     virXMLError(conn, VIR_ERR_XML_ERROR,
-                                "too many boot devices", 0);
+                                _("too many boot devices"), 0);
                     return (-1);
                 }
                 if (xmlStrEqual(boot_dev, BAD_CAST "fd")) {
@@ -1004,7 +1004,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
                 isMouse = 0;
             else if (strcmp((const char *) itype, "mouse")) {
                 xmlFree(itype);
-                virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0);
+                virXMLError(conn, VIR_ERR_XML_ERROR,
+                            _("invalid input device"), 0);
                 goto error;
             }
             xmlFree(itype);
@@ -1020,7 +1021,8 @@ virDomainParseXMLOSDescHVM(virConnectPtr conn, xmlNodePtr node,
                 if (!strcmp((const char *) bus, "ps2")) {
                     if (!isMouse) {
                         xmlFree(bus);
-                        virXMLError(conn, VIR_ERR_XML_ERROR, "input", 0);
+                        virXMLError(conn, VIR_ERR_XML_ERROR,
+                                    _("invalid input device"), 0);
                         goto error;
                     }
                     /* Nothing - implicit ps2 */
diff --git a/src/xmlrpc.c b/src/xmlrpc.c
index ac4ea6e..5baa353 100644
--- a/src/xmlrpc.c
+++ b/src/xmlrpc.c
@@ -50,7 +50,7 @@ static xmlRpcValuePtr xmlRpcValueNew(xmlRpcValueType type)
     xmlRpcValuePtr ret = malloc(sizeof(*ret));
     
     if (!ret)
-        xmlRpcError(VIR_ERR_NO_MEMORY, "allocate value", sizeof(*ret));
+	xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate value"), sizeof(*ret));
     else
         ret->kind = type;
     return ret;
@@ -183,7 +183,7 @@ static xmlRpcValueDictElementPtr xmlRpcValueUnmarshalDictElement(xmlNodePtr node
     xmlNodePtr cur;

     if (!ret) {
-        xmlRpcError(VIR_ERR_NO_MEMORY, "allocate dict", sizeof(*ret));
+	xmlRpcError(VIR_ERR_NO_MEMORY, _("allocate dict"), sizeof(*ret));
 	return NULL;
     }
     memset(ret, 0, sizeof(*ret));
-- 
1.5.4.19.gd3dfd

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]