[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
argp mishandles domains
From: |
Colin Watson |
Subject: |
argp mishandles domains |
Date: |
Mon, 10 Mar 2008 11:50:43 +0000 |
User-agent: |
Mutt/1.5.13 (2006-08-11) |
On Sun, Mar 09, 2008 at 02:47:55PM +0100, Robert Luberda wrote:
> On the other hand while testing updated message catalogue translations I
> noticed, that man seems not to use translations from the
> man-db-gnulib.mo file, for example it shows untranslated messages
>
> [17]/tmp> LC_ALL=pl_PL man --help | grep help
> -?, --help give this help list
>
> even though translation is available:
>
> [19]/usr/share/locale/pl/LC_MESSAGES> msgunfmt man-db-gnulib.mo | grep
> -1 'give this help'
>
> msgid "give this help list"
> msgstr "wyĆwietlenie tego tekstu pomocy"
This appears to be a Gnulib bug.
man-db sets its default text domain to "man-db", and keeps all Gnulib's
strings in a separate "man-db-gnulib" domain, using 'gnulib-tool
--po-domain=man-db' which results in
-DDEFAULT_TEXT_DOMAIN=\"man-db-gnulib\". (I checked this general
approach with Bruno a while back and he said it was fine.)
However, Gnulib's argp implementation has three bugs which cause this
not to work properly:
* It hardcodes "libc" as a domain in two places. This is obviously
wrong in Gnulib.
* It uses argp_domain as both the domain used to translate its own
strings (i.e. string literals in lib/argp-*.c) and the domain used
to translate strings provided by the user, which normally have to
use gettext_noop so that they can be used as 'struct argp_option'
initialisers. This is dreadfully inconvenient because you have to
copy strings about all over the place and keep your POT file up to
date as the argp implementation changes. If argp is in libc then
this is obviously impossible.
Instead, argp should use DEFAULT_TEXT_DOMAIN to translate its own
string literals (falling back to the default program domain if that
is not set), and should reserve argp_domain for translating strings
that appear in that argp structure.
* In a number of places, argp uses the domain of the root argp
structure when translating text from a child argp structure. This is
the direct cause of Robert's bug, because the standard --help and
--version options are implemented as a child argp structure with its
own domain.
My patch changes this to use argp_domain from the child instead.
However, on reflection, I'm not certain that this is correct;
arguably it needs to walk up the tree until it finds a domain to
use. This depends on whether you think that argp_domain == NULL
means "use default program domain" or "use same domain as parent
argp structure".
Could somebody review the attached patch and see if it looks right?
2008-03-10 Colin Watson <address@hidden>
* lib/argp-help.c: Define ARGP_TEXT_DOMAIN to
DEFAULT_TEXT_DOMAIN if set.
(validate_uparams, fill_in_uparams, hol_help, _help)
(__argp_failure): Use our default domain rather than the
provided argp_domain to translate our own strings.
(hol_entry_help): Translate user strings using the appropriate
child argp_domain, rather than that from the root argp.
* lib/argp-parse.c: Define ARGP_TEXT_DOMAIN to
DEFAULT_TEXT_DOMAIN if set.
(argp_default_argp, argp_version_argp): Set argp_domain to
ARGP_TEXT_DOMAIN rather than "libc".
(argp_version_parser, parser_finalize, parser_parse_opt): Use
our default domain rather than the provided argp_domain to
translate our own strings.
Thanks,
--
Colin Watson address@hidden
gnulib.argp-domain.diff
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- argp mishandles domains,
Colin Watson <=