Web blog of yydzero
姚延栋(Yandong Yao)的博客
归档
« 十一月 2009
星期日星期一星期二星期三星期四星期五星期六
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
     
       
今天
Click me to subscribe
Search In My Blog

链接
 

今日点击: 76

Locations of visitors to this page
« Display Name of... | Main | The encoding returne... »
星期六 一月 14, 2006
The encoding of messages file and encoding of gettext()

po file are handled by gettext/dgettext/dcgettext.

  1. The encoding of po file is specified in po file through 'charset' keyword, gnome messages files are utf8.
  2. The output encoding of gettext is dependent to LC_CTYPE at default
  3. 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);

  1. What is message domain?
    1. A set of translatabel msgid messages.
    2. Use domain name to determine where the translation is looked up.
  2. The message domain of gettext is specified by a preceding textdomain call.
  3. Translation Operation
    1. 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.
    2. 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.
Posted at 11:57下午 一月 14, 2006 by Yaodong Zero Yao in gnome  |  评论[1]

评论:

Hmm, the encoding is true only if you're using GNU gettext - with Solaris gettext, the encoding of the message file is assumed to be the same encoding used by the locale that's processing the compiled .mo file. Solaris gettext didn't support the charset header comment. More info in the msgfmt man page (which I'm glad to see on Solaris has been updated to be able to support both GNU and Solaris message files)

发表于 Tim Foster 在 2006年01月15日, 09:45 上午 CST #

发表一条评论:
  • HTML语法: 禁用