⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nls.sgml

📁 PostgreSQL 8.1.4的源码 适用于Linux下的开源数据库系统
💻 SGML
📖 第 1 页 / 共 2 页
字号:
<!--$PostgreSQL: pgsql/doc/src/sgml/nls.sgml,v 1.13 2005/11/04 23:14:00 petere Exp $--><chapter id="nls"> <chapterinfo>  <author>   <firstname>Peter</firstname>   <surname>Eisentraut</surname>  </author> </chapterinfo> <title>Native Language Support</title> <sect1 id="nls-translator">  <title>For the Translator</title>  <para>   <productname>PostgreSQL</>   programs (server and client) can issue their messages in   your favorite language &mdash; if the messages have been translated.   Creating and maintaining translated message sets needs the help of   people who speak their own language well and want to contribute to   the <productname>PostgreSQL</> effort.  You do not have to be a   programmer at all   to do this.  This section explains how to help.  </para>  <sect2>   <title>Requirements</title>   <para>    We won't judge your language skills &mdash; this section is about    software tools.  Theoretically, you only need a text editor.  But    this is only in the unlikely event that you do not want to try out    your translated messages.  When you configure your source tree, be    sure to use the <option>--enable-nls</option> option.  This will    also check for the <application>libintl</application> library and the    <filename>msgfmt</filename> program, which all end users will need    anyway.  To try out your work, follow the applicable portions of    the installation instructions.   </para>   <para>    If you want to start a new translation effort or want to do a    message catalog merge (described later), you will need the    programs <filename>xgettext</filename> and    <filename>msgmerge</filename>, respectively, in a GNU-compatible    implementation.  Later, we will try to arrange it so that if you    use a packaged source distribution, you won't need    <filename>xgettext</filename>.  (From CVS, you will still need    it.)  <application>GNU Gettext 0.10.36</application> or later is currently recommended.   </para>   <para>    Your local gettext implementation should come with its own    documentation.  Some of that is probably duplicated in what    follows, but for additional details you should look there.   </para>  </sect2>  <sect2>   <title>Concepts</title>   <para>    The pairs of original (English) messages and their (possibly)    translated equivalents are kept in <firstterm>message    catalogs</firstterm>, one for each program (although related    programs can share a message catalog) and for each target    language.  There are two file formats for message catalogs:  The    first is the <quote>PO</quote> file (for Portable Object), which    is a plain text file with special syntax that translators edit.    The second is the <quote>MO</quote> file (for Machine Object),    which is a binary file generated from the respective PO file and    is used while the internationalized program is run.  Translators    do not deal with MO files; in fact hardly anyone does.   </para>   <para>    The extension of the message catalog file is to no surprise either    <filename>.po</filename> or <filename>.mo</filename>.  The base    name is either the name of the program it accompanies, or the    language the file is for, depending on the situation.  This is a    bit confusing.  Examples are <filename>psql.po</filename> (PO file    for psql) or <filename>fr.mo</filename> (MO file in French).   </para>   <para>    The file format of the PO files is illustrated here:<programlisting># commentmsgid "original string"msgstr "translated string"msgid "more original"msgstr "another translated""string can be broken up like this"...</programlisting>    The msgid's are extracted from the program source.  (They need not    be, but this is the most common way.)  The msgstr lines are    initially empty and are filled in with useful strings by the    translator.  The strings can contain C-style escape characters and    can be continued across lines as illustrated.  (The next line must    start at the beginning of the line.)   </para>   <para>    The # character introduces a comment.  If whitespace immediately    follows the # character, then this is a comment maintained by the    translator.  There may also be automatic comments, which have a    non-whitespace character immediately following the #.  These are    maintained by the various tools that operate on the PO files and    are intended to aid the translator.<programlisting>#. automatic comment#: filename.c:1023#, flags, flags</programlisting>    The #. style comments are extracted from the source file where the    message is used.  Possibly the programmer has inserted information    for the translator, such as about expected alignment.  The #:    comment indicates the exact location(s) where the message is used    in the source.  The translator need not look at the program    source, but he can if there is doubt about the correct    translation.  The #, comments contain flags that describe the    message in some way.  There are currently two flags:    <literal>fuzzy</literal> is set if the message has possibly been    outdated because of changes in the program source.  The translator    can then verify this and possibly remove the fuzzy flag.  Note    that fuzzy messages are not made available to the end user.  The    other flag is <literal>c-format</literal>, which indicates that    the message is a <function>printf</function>-style format    template.  This means that the translation should also be a format    string with the same number and type of placeholders.  There are    tools that can verify this, which key off the c-format flag.   </para>  </sect2>  <sect2>   <title>Creating and maintaining message catalogs</title>   <para>    OK, so how does one create a <quote>blank</quote> message    catalog?  First, go into the directory that contains the program    whose messages you want to translate.  If there is a file    <filename>nls.mk</filename>, then this program has been prepared    for translation.   </para>   <para>    If there are already some <filename>.po</filename> files, then    someone has already done some translation work.  The files are    named <filename><replaceable>language</replaceable>.po</filename>,    where <replaceable>language</replaceable> is the     <ulink url="http://lcweb.loc.gov/standards/iso639-2/englangn.html">    ISO 639-1 two-letter language code (in lower case)</ulink>, e.g.,    <filename>fr.po</filename> for French.  If there is really a need    for more than one translation effort per language then the files    may also be named    <filename><replaceable>language</replaceable>_<replaceable>region</replaceable>.po</filename>    where <replaceable>region</replaceable> is the    <ulink url="http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/en_listp1.html">    ISO 3166-1 two-letter country code (in upper case)</ulink>,    e.g.,    <filename>pt_BR.po</filename> for Portuguese in Brazil.  If you    find the language you wanted you can just start working on that    file.   </para>   <para>    If you need to start a new translation effort, then first run the    command<programlisting>gmake init-po</programlisting>    This will create a file    <filename><replaceable>progname</replaceable>.pot</filename>.    (<filename>.pot</filename> to distinguish it from PO files that    are <quote>in production</quote>. The <literal>T</> stands for    <quote>template</>.)    Copy this file to    <filename><replaceable>language</replaceable>.po</filename> and    edit it.  To make it known that the new language is available,    also edit the file <filename>nls.mk</filename> and add the    language (or language and country) code to the line that looks like:<programlisting>AVAIL_LANGUAGES := de fr</programlisting>    (Other languages may appear, of course.)   </para>   <para>    As the underlying program or library changes, messages may be    changed or added by the programmers.  In this case you do not need    to start from scratch.  Instead, run the command<programlisting>gmake update-po</programlisting>    which will create a new blank message catalog file (the pot file    you started with) and will merge it with the existing PO files.    If the merge algorithm is not sure about a particular message it    marks it <quote>fuzzy</quote> as explained above.  For the case    where something went really wrong, the old PO file is saved with a    <filename>.po.old</filename> extension.   </para>  </sect2>  <sect2>   <title>Editing the PO files</title>   <para>    The PO files can be edited with a regular text editor.  The    translator should only change the area between the quotes after    the msgstr directive, may add comments and alter the fuzzy flag.    There is (unsurprisingly) a PO mode for Emacs, which I find quite    useful.   </para>   <para>    The PO files need not be completely filled in.  The software will    automatically fall back to the original string if no translation    (or an empty translation) is available.  It is no problem to    submit incomplete translations for inclusions in the source tree;    that gives room for other people to pick up your work.  However,    you are encouraged to give priority to removing fuzzy entries    after doing a merge.  Remember that fuzzy entries will not be    installed; they only serve as reference what might be the right    translation.   </para>   <para>    Here are some things to keep in mind while editing the    translations:    <itemizedlist>     <listitem>      <para>       Make sure that if the original ends with a newline, the       translation does, too.  Similarly for tabs, etc.      </para>     </listitem>     <listitem>      <para>       If the original is a <function>printf</> format string, the translation       also needs to be.  The translation also needs to have the same       format specifiers in the same order.  Sometimes the natural       rules of the language make this impossible or at least awkward.       In that case you can modify the format specifiers like this:<programlisting>msgstr "Die Datei %2$s hat %1$u Zeichen."</programlisting>       Then the first placeholder will actually use the second

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -