This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Supporting multiple gettext directories


Hi glibc developers!

In Ubuntu we introduced the concept of "language packs" which ship all
gettext mo files for one language in one package (for various
reasons). This requires us to support an additional gettext file
hierarchy /usr/share/locale-langpack/ besides /usr/share/locale/. If a
mo file is present in only one directory, it is used; if it is present
in both, the file with the newest modification time is used.

Currently I implement this decision in DCIGETTEXT() in
intl/dcigettext.c of the glibc. Roughly I do

        domain = _nl_find_domain (dirname, single_locale, xdomainname, binding);
        domain2 = _nl_find_domain ("/usr/share/locale-langpack", single_locale2, xdomainname, binding);

Then I iterate through all found domains of both trees, stat() the
files and compare timestamps. This works fine, however, it is very
inefficient since this function is called for every string. Simply
caching a single value whether to use /usr/share/locale or
locale-langpack breaks if an application uses several translation
domains (e. g. a Gnome application uses several ones: gtk, atk, maybe
gstreamer, and an application-specific one).

So I currently think about implementing a mapping domain ->resultcache
mapping in dcigettext.c, with resultcache being 0 for undecided, 1
for /usr/share/locale, and 2 for /usr/share/locale-langpack/. But
doing this in C is awful, and I don't want to modify the  struct
loaded_l10nfile either since this is public.

Do you happen to have a good idea how this can be handled less
intrusively and more efficient than in dcigettext()? Can such a
feature (supporting several gettext directories) eventually be adopted
upstream? I think an extension of bindtextdomain() to allow several
dirnames (in an array, or separated by ':') would be cool.

Thanks in advance for any hint and have a nice day!

Martin
-- 
Martin Pitt                       http://www.piware.de
Ubuntu Developer            http://www.ubuntulinux.org
Debian GNU/Linux Developer       http://www.debian.org

Attachment: signature.asc
Description: Digital signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]