Client localization design issues

Greg Hudson ghudson at MIT.EDU
Sun Jun 5 18:26:32 EDT 2011


I discussed com_err localization design a bit with Ted Ts'o (who
maintains e2fsprogs, which contains the version of com_err used to build
krb5 on Debian), and he raised a couple of design considerations:

* In some uses (e2fsprogs in particular), error tables are initialized
by library callers, who don't have much interest in the library's text
domain and certainly don't know the locale directory.  In those cases,
it would be useful if the generated C file contained the text domain and
the locale directory, and for libcom_err to call bindtextdomain().

* There's a clever place to store this information.  Right now every
version of compile_et puts a null entry at the end of the error table
(though the libcom_err code doesn't need it), but the error table also
has a table length in the n_msgs field.  So we can store additional
strings in msgs[n_msgs] and following, using the terminating null entry
to tell where the extra strings end.

To avoid putting the locale directory into .et files (since it depends
on build options), I figured new compile_et options were the way to go.
So I'm thinking:

1. Add --textdomain and --localedir options to compile_et.  A text
domain is required for a locale directory, but not vice versa.  The text
domain is stored in msgs[n_msgs] if given, and the locale directory in
msgs[n_msgs + 1].

2. If an error table contains a text domain, error_message() will call
dgettext on the error string.

3. If an error table contains a locale directory, add_error_table() will
call bindtextdomain() for the error table's text domain.

krb5 would likely use the --textdomain option but not the --localedir
option.  We'd use an autoconf text to check whether --textdomain is
supported when using the system com_err, and translate com_err results
in krb5int_get_error if it's not.

Also, for ease of generating pot files, compile_et would #define N_() to
a no-op and surround actual error strings (but not extra strings) with
N_().  This allows the use of xgettext -kN_ instead of xgettext -a,
which would generate a bogus entry for the text domain string.





More information about the krbdev mailing list