This implementation of NLS does not use GNU gettext. The reasons are: More...
Macros | |
#define | NLS_COMMENT(comment) |
Always remove NLS comments from code. | |
#define | MAIN_ERR_PREFIX "NLS: " |
Message prefix for NLS module. | |
#define | NLS_MAX_MESSAGE 384 |
Maximum number of messages loaded from NLS catalog. More... | |
Enumerations | |
enum | nls_locale { NLS_LOCALE_VALID, NLS_LOCALE_DEFAULT, NLS_LOCALE_INVALID } |
Functions | |
int | nls_init (void) |
Init NLS subsystem. More... | |
void | nls_exit (void) |
Shutdown NLS subsystem. More... | |
const char * | nls_getstring (int n, const char *s) |
Get NLS string. More... | |
Variables | |
char | nls_loc [6] = "" |
Current NLS locale. | |
This implementation of NLS does not use GNU gettext. The reasons are:
This should waste minimum ressources and give best runtime performance. All the expensive work is done only once at build time.
#define NLS_MAX_MESSAGE 384 |
Maximum number of messages loaded from NLS catalog.
This value must at least match the number of messages in the NLS catalogs used by the program. The limit of this implementation is INT_MAX. If the system has a lower limit than the configured value, the value is clamped to the system limit.
void nls_exit | ( | void | ) |
Shutdown NLS subsystem.
It is allowed to call this function even if nls_init() have failed. In this case it simply does nothing.
const char* nls_getstring | ( | int | n, |
const char * | s | ||
) |
Get NLS string.
[in] | n | NLS string number |
[in] | s | Replacement string if translation for string n was not found |
It is allowed to call this function even if nls_init() have failed or after nls_exit() . In this case always s is returned.
int nls_init | ( | void | ) |
Init NLS subsystem.
First the locale of the program is set. If this fails the locale POSIX
is used. The locale C
is also mapped to POSIX
and no NLS catalog is used for the locale POSIX
. Then we try to extract the language code xx
and the country code YY
of the message locale name from LC_MESSAGES
. If the locale has no country code (old 2 digit style), XX
is used. If a valid locale was found, a catalog with the name xx_YY.cat
is searched in the location CFG_NLS_PATH
that was compiled into the program.
NLSPATH
is ignored for security reasons. The administrator who installed the program should have control over the NLS strings that are processed by the program. Think twice before changing this because we use Unicode NLS catalogs and the validity of the encoding must be verfied at runtime otherwise.