po file are handled by gettext/dgettext/dcgettext.
- The encoding of po file is specified in po file through 'charset' keyword, gnome messages files are utf8.
- The output encoding of gettext is dependent to LC_CTYPE at default
- You can use bind_textdomain_codeset() to specify what encoding of the output of gettext is.
char * gettext(const char *msgid);
char * dgettext(const char *domainname, const char * msgid);
char * dcgettext(const char *domainname, const char *msgid, int category);
- What is message domain?
- A set of translatabel msgid messages.
- Use domain name to determine where the translation is looked up.
- The message domain of gettext is specified by a preceding textdomain call.
- Translation Operation
- gettext, dgettext use LC_MESSAGES to lookup. It is determined by a preceding call to the setlocale function. setlocale(LC_ALL, "") initializes the LC_MESSAGE locale based on the first nonempty value of the three enviroment variabled LC_ALL, LC_MESSAGES, LANG.
- Use LC_CTYPE to convert the translated message from the translator's codeset(specified in po file, mostly is UTF-8) to the current locale's codeset. You can use bint_textdomain_codeset to specify the output messages encoding.
发表于 Tim Foster 在 2006年01月15日, 09:45 上午 CST #