[Libvir] 0/9: mark error messages as translatable

Jim Meyering jim at meyering.net
Wed Mar 26 18:57:18 UTC 2008

Daniel Veillard <veillard at redhat.com> wrote:
> On Mon, Mar 24, 2008 at 12:26:51PM +0100, Jim Meyering wrote:
>> Daniel Veillard <veillard at redhat.com> wrote:
>> > On Sun, Mar 23, 2008 at 07:50:24PM +0100, Guido Günther wrote:
>> >> This patch marks the error messages in qemu_driver.c as translatable,
>> >> some of them were marked as such already. Please apply.
>> > [...]
>> >>          qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
>> >> -                         "cannot create bridge '%s' : %s", name, strerror(err));
>> >> +                         _("cannot create bridge '%s' : %)"), name, strerror(err));
>> >
>> >  Patch is a bit broken here, otherwise that looks fine. I'm wondering why
>> > that wasn't check by 'make syntax-check' as other modules are checked for
>> > translatable strings.
>> I explained why, fixed the underlying problem,
>> and fixed about 1/3 of the violations it exposed
>> with this big patch:
>>   http://thread.gmane.org/gmane.comp.emulators.libvirt/5374
>> But for your objection, I would have applied that change weeks ago.
>> I've been waiting for a reply to my question at the end of the thread:
>>   http://thread.gmane.org/gmane.comp.emulators.libvirt/5374/focus=5382
>   My recollection is that I objected to a bunch of non-translatable strings
> from the protocol module, Guido patch was about qemu_driver.c errors which
> had translatable meaning. Maybe there is some overlap, but it looks different.
> To me adding comments to C files to tag the fact that untranslatable strings
> are now marked as translatable to allow an automatic check in the hope that
> the translators will see those comments (with whatever tools they have) and
> won't loose time on those strings didn't made much sense to me (and still
> don't honnestly).
>   Either remove the check from the protocol module and and commit the other
> parts, or just ignore me and commit the full thing. As you pointed out you're
> not responsible for the multiplication of those debugging strings in that
> module.

I've marked many more strings.
For some of the offending ones (all matching "VAR > MAX_.*"),
I rewrote the diagnostic to say something more meaningful, and to include
the actual values via a format like _("translatable message...: %d > %d"),
e.g. (from 0005):

-        error (conn, VIR_ERR_RPC, _("maxids > REMOTE_DOMAIN_ID_LIST_MAX"));
+        errorf (conn, VIR_ERR_RPC,
+                _("too many remote domain IDs: %d > %d"),
+                maxids, REMOTE_DOMAIN_ID_LIST_MAX);

Also, in qemu_conf.c, there were a lot of one-word VIR_ERR_NO_MEMORY
strings.  I have changed them so that at least the latter part of
the message ends up being translatable.  Here are two examples:

diff --git a/src/qemu_conf.c b/src/qemu_conf.c
index f6ae06b..bafea8c 100644
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -82,7 +82,7 @@ int qemudLoadDriverConfig(struct qemud_driver *driver,
     strcpy(driver->vncListen, "");
     if (!(driver->vncTLSx509certdir = strdup(SYSCONF_DIR "/pki/libvirt-vnc"))) {
         qemudReportError(NULL, NULL, NULL, VIR_ERR_NO_MEMORY,
-                         "vncTLSx509certdir");
+                         "%s", _("failed to allocate vncTLSx509certdir"));

-                qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY, "disk");
+                qemudReportError(conn, NULL, NULL, VIR_ERR_NO_MEMORY,
+                           "%s", _("failed to allocate space for disk string"));

There are still some strings of the form "function_name: keyword".
I'm sure someone who cares will go find all of them and replace
them, as I've done for some of the others.

I've left the checking of error() diagnostics disabled,
because there are a few remaining untranslatable messages,
and I don't have the energy now to fix them:

    src/openvz_conf.c:251:  error(conn, VIR_ERR_NO_MEMORY, "vm");
    src/openvz_conf.c:302:  error(conn, VIR_ERR_NO_MEMORY, "xmlXPathContext");
    src/openvz_conf.c:316:  error(conn, VIR_ERR_NO_MEMORY, "xmlXPathContext");
    src/openvz_driver.c:155:error(conn, VIR_ERR_NO_MEMORY, "virDomainPtr");
    src/openvz_driver.c:183:error(conn, VIR_ERR_NO_MEMORY, "virDomainPtr");
    src/openvz_driver.c:204:error(conn, VIR_ERR_NO_MEMORY, "virDomainPtr");
    src/openvz_driver.c:262:error(dom->conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);
    src/openvz_driver.c:306:error(dom->conn, VIR_ERR_INTERNAL_ERROR, "Could not exec " VZLIST);

If someone is interested, just change the diagnostics, mark them with
_(...), and when they're all done, uncomment this line in Makefile.maint:

    # msg_gen_function += error

Likewise for a few other functions.
Here's the list, from Makefile.maint:

  # Uncomment the following and run "make syntax-check" to see diagnostics
  # that are not yet marked for translation, but that need to be rewritten
  # so that they are translatable.
  # msg_gen_function += error
  # msg_gen_function += virXenError
  # msg_gen_function += testError
  # msg_gen_function += lxcError

Much of the first patch you've seen before, but I redid the Makefile.maint
function list to use += rather than backslash-continued lines
(slightly more maintainable), and then added a few more functions to the list.

I expect to commit this tomorrow morning.

More information about the libvir-list mailing list