Difference between revisions of "Projects/Localization"
(New page: {{project-early}} {{project-target|1.10}} ==Overview== The purpose of this project is to add infrastructure for localization of user interface messages in the krb5 tree, using gettext. ...) |
(→Design) |
||
Line 7: | Line 7: | ||
==Design== |
==Design== |
||
+ | |||
+ | ===Basic infrastructure=== |
||
+ | |||
+ | Macros will be added to k5-platform.h to define _() and N_(), and to null out calls to bindtextdomain(), setlocale(), and dgettext() when krb5 is built without localization support. |
||
A single text domain, mit-krb5, will be used for all messages. |
A single text domain, mit-krb5, will be used for all messages. |
||
− | + | krb5int_lib_init() will be extended to call bindtextdomain() for the mit-krb5 textdomain. |
|
− | Strings in the tree which should be translated will be marked up with _(), which will be defined to dgettext("mit-krb5", string) when built with localization support. |
+ | Strings in the tree which should be translated will be marked up with _(), which will be defined to dgettext("mit-krb5", string) when built with localization support. Strings which will be translated later will be marked up with N_(). |
− | com_err messages will be translated in krb5_get_error_message(). This will not reach direct uses of the com_err library, but will work when krb5 is built against an external com_err library. Any direct uses of error_message() or com_err() without an appropriate hook should be identified and corrected. |
||
+ | Build infrastructure will be added to run xgettext to extract marked strings from C source files into a pot file, and to convert po files into mo files and install them. |
||
− | Build infrastructure will be added to run xgettext to extract marked strings. For com_err tables, we can either run xgettext over the generated source files in the build tree, or extend compile_et to generate pot file entries. Further investigation is required to determine the simplest approach. |
||
+ | ===com_err library=== |
||
+ | |||
+ | There are several versions of the com_err library. MIT krb5 is typically built either with its own internal version of com_err, or with the system com_err which typically comes from e2fsprogs. The following changes will be made to the internal krb5 com_err and have also been submitted to the e2fsprogs maintainer for its version of com_err: |
||
+ | |||
+ | * compile_et defines N_() to a no-op and marks up error message strings with it. |
||
+ | * If compile_et is passed the --textdomain option, it stores the text domain as a string at the end of the error table, before the null terminator. |
||
+ | * If compile_et is also passed the --localedir option, it stores it in the error table after the text domain. |
||
+ | * If an error table has a text domain, error_message() will call dgettext on the text domain and error string. |
||
+ | * If an error table also has a locale directory, add_error_table() will call bindtextdomain on the text domain and locale direcetory. |
||
+ | |||
+ | If we build against a system com_err with no support for compile_et --textdomain, we will translate com_err results in krb5int_get_error(), which should reach most uses. |
||
Programs in the tree such as kinit will call setlocale() at startup. |
Programs in the tree such as kinit will call setlocale() at startup. |
||
The test framework will be modified to set the locale to C to ensure that it sees the expected (untranslated) output. |
The test framework will be modified to set the locale to C to ensure that it sees the expected (untranslated) output. |
||
+ | |||
+ | ===Markup=== |
||
==Relevant Mailing List Threads== |
==Relevant Mailing List Threads== |
Revision as of 10:08, 9 June 2011
Contents
Overview
The purpose of this project is to add infrastructure for localization of user interface messages in the krb5 tree, using gettext.
Design
Basic infrastructure
Macros will be added to k5-platform.h to define _() and N_(), and to null out calls to bindtextdomain(), setlocale(), and dgettext() when krb5 is built without localization support.
A single text domain, mit-krb5, will be used for all messages.
krb5int_lib_init() will be extended to call bindtextdomain() for the mit-krb5 textdomain.
Strings in the tree which should be translated will be marked up with _(), which will be defined to dgettext("mit-krb5", string) when built with localization support. Strings which will be translated later will be marked up with N_().
Build infrastructure will be added to run xgettext to extract marked strings from C source files into a pot file, and to convert po files into mo files and install them.
com_err library
There are several versions of the com_err library. MIT krb5 is typically built either with its own internal version of com_err, or with the system com_err which typically comes from e2fsprogs. The following changes will be made to the internal krb5 com_err and have also been submitted to the e2fsprogs maintainer for its version of com_err:
- compile_et defines N_() to a no-op and marks up error message strings with it.
- If compile_et is passed the --textdomain option, it stores the text domain as a string at the end of the error table, before the null terminator.
- If compile_et is also passed the --localedir option, it stores it in the error table after the text domain.
- If an error table has a text domain, error_message() will call dgettext on the text domain and error string.
- If an error table also has a locale directory, add_error_table() will call bindtextdomain on the text domain and locale direcetory.
If we build against a system com_err with no support for compile_et --textdomain, we will translate com_err results in krb5int_get_error(), which should reach most uses.
Programs in the tree such as kinit will call setlocale() at startup.
The test framework will be modified to set the locale to C to ensure that it sees the expected (untranslated) output.
Markup
Relevant Mailing List Threads
http://mailman.mit.edu/pipermail/krbdev/2011-May/010011.html