Home Explore Blog CI



postgresql

6th chunk of `doc/src/sgml/nls.sgml`
db5dca3e75e23f08388cfd21dfc1d0a0f585f011dec8458300000001000009c5
 contains one file name per
         line.
        </para>
       </listitem>
      </varlistentry>

      <varlistentry>
       <term><varname>GETTEXT_TRIGGERS</varname></term>

       <listitem>
        <para>
         The tools that generate message catalogs for the translators
         to work on need to know what function calls contain
         translatable strings.  By default, only
         <function>gettext()</function> calls are known.  If you used
         <function>_</function> or other identifiers you need to list
         them here.  If the translatable string is not the first
         argument, the item needs to be of the form
         <literal>func:2</literal> (for the second argument).
         If you have a function that supports pluralized messages,
         the item should look like <literal>func:1,2</literal>
         (identifying the singular and plural message arguments).
        </para>
       </listitem>
      </varlistentry>
     </variablelist>
    </para>
   </step>

   <step>
    <para>
     Add a file <filename>po/LINGUAS</filename>, which will contain the list
     of provided translations &mdash; initially empty.
    </para>
   </step>
  </procedure>

  <para>
   The build system will automatically take care of building and
   installing the message catalogs.
  </para>
  </sect2>

  <sect2 id="nls-guidelines">
   <title>Message-Writing Guidelines</title>

  <para>
   Here are some guidelines for writing messages that are easily
   translatable.

   <itemizedlist>
    <listitem>
     <para>
      Do not construct sentences at run-time, like:
<programlisting>
printf("Files were %s.\n", flag ? "copied" : "removed");
</programlisting>
      The word order within the sentence might be different in other
      languages.  Also, even if you remember to call <function>gettext()</function> on
      each fragment, the fragments might not translate well separately.  It's
      better to duplicate a little code so that each message to be
      translated is a coherent whole.  Only numbers, file names, and
      such-like run-time variables should be inserted at run time into
      a message text.
     </para>
    </listitem>

    <listitem>
     <para>
      For similar reasons, this won't work:
<programlisting>
printf("copied %d file%s", n, n!=1 ? "s" : "");
</programlisting>
      because it assumes how the plural is formed.  If you figured you
      could solve it like this:
<programlisting>
if (n==1)
    printf("copied 1 file");
else

Title: Guidelines for Writing Translatable Messages
Summary
This section provides guidelines for writing messages that can be easily translated, including avoiding the construction of sentences at run-time, not assuming word order or plural formation, and keeping each message as a coherent whole with only run-time variables inserted.