Table of Contents
See the C API pages for other API documentation on globus_common.
The Globus Toolkit C Common Library now has optional infrastructure support for internationalization, which is used by GridFTP and its dependencies (pre-ws authorization/authentication and XIO).
This means that user-presented strings are wrapped in a lookup function, which, if the globus_i18n module is installed and the GLOBUS_I18N environment variable is set to "YES", will lookup the string in a resource bundle using ICU4C. If GLOBUS_I18N is set to "NO", or the globus_i18n module is not installed, or the string value cannot be found in the resource bundle, the default string (exactly what was being looked up) is returned.
There are two functions that are used for string lookup.
The first is the preferred function; you supply a module descriptor and the string that you want to look up:
globus_common_i18n_get_string( globus_module_descriptor_t * module, char * key);
The second function is used if you need to look up a particular locale. A NULL value for locale will look up from the default locale:
globus_common_i18n_get_string_by_key( char * locale, char * resource_name, char * key);
Typically, one or more macros will be defined on a per-module basis that supply the module descriptor, to reduce clutter in the code. Within the toolkit, these are typically _???SL where ??? are some mnemonic for the module in question (for example _GCSL is defined for globus_common).
The resource bundles used for the string lookups are created using ICU4C (see IBM documentation on Resource Bundles).
Our resource bundles are very simple; they contain simply a set of keys and strings. The key is actually the string itself: it is hashed using the globus_hashtable_string_hash function, then converted to contain only invariant characters ( #!@[]^`{|}~ are converted to '_'). See globus_i18n_resource_init.c in the globus_i18n source for an example of creating keys.
While resource bundles for the Globus Toolkit are not by default created as part of the build process nor distributed in our binary distributions, there is a tool distributed with the globus_i18n package that makes them simple to construct.
Invoking globus-i18n-resource-create <module name> from the top level directory of a built (or at least configured) source package will generate a resource bundle for that package which can then be moved to $GLOBUS_LOCATION/share/i18n/
.
globus-i18n-resource-create is part of the globus_i18n package, and will be installed if --enable-i18n was given as a configure option to the installer. globus-i18n-resource-create uses globus-i18n-resource-init and genrb from ICU4C to create the resource bundles.
Resource bundles must be installed in $GLOBUS_LOCATION/share/i18n/
.