Gettext
Gettext 主页
简介:是GNU国际化与本地化(i18n)函数库。它常被用于编写多语言程序。
xgettext: 源代码 => .pot模板文件
# xgettext –help
e.g.
# xgettext -LPHP /xxx/yyy/zzz.php
# xgettext --help
Usage: xgettext [OPTION] [INPUTFILE]...
Extract translatable strings from given input files.
Mandatory arguments to long options are mandatory for short options too.
Similarly for optional arguments.
Input file location:
INPUTFILE ... input files
-f, --files-from=FILE get list of input files from FILE
-D, --directory=DIRECTORY add DIRECTORY to list for input files search
If input file is -, standard input is read.
Output file location:
-d, --default-domain=NAME use NAME.po for output (instead of messages.po)
-o, --output=FILE write output to specified file
-p, --output-dir=DIR output files will be placed in directory DIR
If output file is -, output is written to standard output.
Choice of input file language:
-L, --language=NAME recognise the specified language
(C, C++, ObjectiveC, PO, Shell, Python, Lisp,
EmacsLisp, librep, Scheme, Smalltalk, Java,
JavaProperties, C#, awk, YCP, Tcl, Perl, PHP,
GCC-source, NXStringTable, RST, Glade)
-C, --c++ shorthand for --language=C++
By default the language is guessed depending on the input file name extension.
Input file interpretation:
--from-code=NAME encoding of input files
(except for Python, Tcl, Glade)
By default the input files are assumed to be in ASCII.
Operation mode:
-j, --join-existing join messages with existing file
-x, --exclude-file=FILE.po entries from FILE.po are not extracted
-c, --add-comments[=TAG] place comment block with TAG (or those
preceding keyword lines) in output file
Language specific options:
-a, --extract-all extract all strings
(only languages C, C++, ObjectiveC, Shell,
Python, Lisp, EmacsLisp, librep, Scheme, Java,
C#, awk, Tcl, Perl, PHP, GCC-source, Glade)
-k, --keyword[=WORD] additional keyword to be looked for (without
WORD means not to use default keywords)
(only languages C, C++, ObjectiveC, Shell,
Python, Lisp, EmacsLisp, librep, Scheme, Java,
C#, awk, Tcl, Perl, PHP, GCC-source, Glade)
--flag=WORD:ARG:FLAG additional flag for strings inside the argument
number ARG of keyword WORD
(only languages C, C++, ObjectiveC, Shell,
Python, Lisp, EmacsLisp, librep, Scheme, Java,
C#, awk, YCP, Tcl, Perl, PHP, GCC-source)
-T, --trigraphs understand ANSI C trigraphs for input
(only languages C, C++, ObjectiveC)
--qt recognize Qt format strings
(only language C++)
--debug more detailed formatstring recognition result
Output details:
-e, --no-escape do not use C escapes in output (default)
-E, --escape use C escapes in output, no extended chars
--force-po write PO file even if empty
-i, --indent write the .po file using indented style
--no-location do not write '#: filename:line' lines
-n, --add-location generate '#: filename:line' lines (default)
--strict write out strict Uniforum conforming .po file
--properties-output write out a Java .properties file
--stringtable-output write out a NeXTstep/GNUstep .strings file
-w, --width=NUMBER set output page width
--no-wrap do not break long message lines, longer than
the output page width, into several lines
-s, --sort-output generate sorted output
-F, --sort-by-file sort output by file location
--omit-header don't write header with `msgid ""' entry
--copyright-holder=STRING set copyright holder in output
--foreign-user omit FSF copyright in output for foreign user
--msgid-bugs-address=EMAIL@ADDRESS set report address for msgid bugs
-m, --msgstr-prefix[=STRING] use STRING or "" as prefix for msgstr entries
-M, --msgstr-suffix[=STRING] use STRING or "" as suffix for msgstr entries
Informative output:
-h, --help display this help and exit
-V, --version output version information and exit
msginit: .pot模板文件 => .po文件 (翻译者需要工作的对象)
# msginit –help
Creates a new PO file, initializing the meta information with values from the
user’s environment.
# msginit --help
Usage: msginit [OPTION]
Creates a new PO file, initializing the meta information with values from the
user's environment.
Mandatory arguments to long options are mandatory for short options too.
Input file location:
-i, --input=INPUTFILE input POT file
If no input file is given, the current directory is searched for the POT file.
If it is -, standard input is read.
Output file location:
-o, --output-file=FILE write output to specified PO file
If no output file is given, it depends on the --locale option or the user's
locale setting. If it is -, the results are written to standard output.
Input file syntax:
-P, --properties-input input file is in Java .properties syntax
--stringtable-input input file is in NeXTstep/GNUstep .strings syntax
Output details:
-l, --locale=LL_CC set target locale
--no-translator assume the PO file is automatically generated
-p, --properties-output write out a Java .properties file
--stringtable-output write out a NeXTstep/GNUstep .strings file
-w, --width=NUMBER set output page width
--no-wrap do not break long message lines, longer than
the output page width, into several lines
Informative output:
-h, --help display this help and exit
-V, --version output version information and exit
msgfmt: .po文件 => 编译为.mo文件
# msgfmt –help
e.g.
# msgfmt /xxx/yyy/zzz.po
Note:
msgfmt: messages.po: warning: Charset “CHARSET” is not a portable encoding name.
You should update the “CHARSET” with “utf-8″ in zzz.po file.
# msgfmt --help
Usage: msgfmt [OPTION] filename.po ...
Generate binary message catalog from textual translation description.
Mandatory arguments to long options are mandatory for short options too.
Similarly for optional arguments.
Input file location:
filename.po ... input files
-D, --directory=DIRECTORY add DIRECTORY to list for input files search
If input file is -, standard input is read.
Operation mode:
-j, --java Java mode: generate a Java ResourceBundle class
--java2 like --java, and assume Java2 (JDK 1.2 or higher)
--csharp C# mode: generate a .NET .dll file
--csharp-resources C# resources mode: generate a .NET .resources file
--tcl Tcl mode: generate a tcl/msgcat .msg file
--qt Qt mode: generate a Qt .qm file
Output file location:
-o, --output-file=FILE write output to specified file
--strict enable strict Uniforum mode
If output file is -, output is written to standard output.
Output file location in Java mode:
-r, --resource=RESOURCE resource name
-l, --locale=LOCALE locale name, either language or language_COUNTRY
-d DIRECTORY base directory of classes directory hierarchy
The class name is determined by appending the locale name to the resource name,
separated with an underscore. The -d option is mandatory. The class is
written under the specified directory.
Output file location in C# mode:
-r, --resource=RESOURCE resource name
-l, --locale=LOCALE locale name, either language or language_COUNTRY
-d DIRECTORY base directory for locale dependent .dll files
The -l and -d options are mandatory. The .dll file is written in a
subdirectory of the specified directory whose name depends on the locale.
Output file location in Tcl mode:
-l, --locale=LOCALE locale name, either language or language_COUNTRY
-d DIRECTORY base directory of .msg message catalogs
The -l and -d options are mandatory. The .msg file is written in the
specified directory.
Input file syntax:
-P, --properties-input input files are in Java .properties syntax
--stringtable-input input files are in NeXTstep/GNUstep .strings
syntax
Input file interpretation:
-c, --check perform all the checks implied by
--check-format, --check-header, --check-domain
--check-format check language dependent format strings
--check-header verify presence and contents of the header entry
--check-domain check for conflicts between domain directives
and the --output-file option
-C, --check-compatibility check that GNU msgfmt behaves like X/Open msgfmt
--check-accelerators[=CHAR] check presence of keyboard accelerators for
menu items
-f, --use-fuzzy use fuzzy entries in output
Output details:
-a, --alignment=NUMBER align strings to NUMBER bytes (default: 1)
--no-hash binary file will not include the hash table
Informative output:
-h, --help display this help and exit
-V, --version output version information and exit
--statistics print statistics about translations
-v, --verbose increase verbosity level
备注:使用Unix类型操作系统的用户只需设置环境变量中的LC_MESSAGES,程序将自动从相应的.mo 文件中读取语言信息。
Mozilla
Mozilla的架构设计
Creating Applications with Mozilla
DTD (.dtd)
Files containing entities that host the strings from XUL content files.
Property (.properties) or string bundles
Files containing strings that are accessed by JavaScript, C++, and possibly other scripting or component files.
RDF
RDF files are described in XML syntax, so use entities.
HTML and text
Suitable for long text, HTML and XML documents and other content that needs to be localized.