Blame Artworks/Docs/Docbook/Tcar-ug/Scripts/Bash/locale.docbook

Alain Reguera Delgado 46de3c
<refentry id="scripts-bash-locale">
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refmeta>
Alain Reguera Delgado 46de3c
        <refentrytitle>locale</refentrytitle>
Alain Reguera Delgado 46de3c
        <indexterm type="specific-function">
Alain Reguera Delgado 46de3c
            <primary>Standardize translation tasks inside &TCAR;</primary>
Alain Reguera Delgado 46de3c
        </indexterm>
Alain Reguera Delgado 46de3c
    </refmeta>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refnamediv>
Alain Reguera Delgado 46de3c
        <refname>locale</refname>
Alain Reguera Delgado 46de3c
        <refpurpose>Standardize translation tasks inside &TCAR;</refpurpose>
Alain Reguera Delgado 46de3c
    </refnamediv>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refsynopsisdiv>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        The <varname>DIRECTORY</varname> parameter specifies the
Alain Reguera Delgado 46de3c
        directory path, inside the working copy of &TCAR;, where the
Alain Reguera Delgado 46de3c
        files you want to process are stored in.  This paramter can be
Alain Reguera Delgado 46de3c
        provided more than once in order to process more than one
Alain Reguera Delgado 46de3c
        directory path in a single command execution.  When this
Alain Reguera Delgado 46de3c
        parameter is not provided, the current directory path where
Alain Reguera Delgado 46de3c
        the command was called from is used instead.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </refsynopsisdiv>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refsection id="scripts-bash-locale-options">
Alain Reguera Delgado 46de3c
    <title>Options</title>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        The <function>locale</function> functionality accepts the
Alain Reguera Delgado 46de3c
        following options: 
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <variablelist>
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--quiet</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Supress all output messages except error messages.  When this
Alain Reguera Delgado 46de3c
        option is passed, all confirmation requests are supressed and
Alain Reguera Delgado 46de3c
        a possitive answer is assumed for them, just as if the
Alain Reguera Delgado 46de3c
        <option>--answer-yes</option> option would have been provided.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--answer-yes</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
       Assume <emphasis>yes</emphasis> to all confirmation requests.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--filter="REGEX"</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Reduce the list of files to process inside
Alain Reguera Delgado 46de3c
        <varname>DIRECTORY</varname> using <varname>REGEX</varname> as
Alain Reguera Delgado 46de3c
        pattern.  You can use this option to control the amount of
Alain Reguera Delgado 46de3c
        files you want to locale.  The deeper you go into the
Alain Reguera Delgado 46de3c
        directory structure the more specific you'll be about the
Alain Reguera Delgado 46de3c
        files you want to locale.  When you cannot go deeper into the
Alain Reguera Delgado 46de3c
        directory structure through <varname>DIRECTORY</varname>
Alain Reguera Delgado 46de3c
        specification, use this option to reduce the list of files
Alain Reguera Delgado 46de3c
        therein.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--synchronize</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Synchronizes available changes between the working copy and
Alain Reguera Delgado 46de3c
        the central repository.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--update</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This option updates both POT and PO files related to source
Alain Reguera Delgado 46de3c
        files.  Use this option everytime you change translatable
Alain Reguera Delgado 46de3c
        strings inside the source files.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--edit</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This option edits the portable object related to source files.
Alain Reguera Delgado 46de3c
        When you provide this option, your default text editor is used
Alain Reguera Delgado 46de3c
        to open the portable object you, as translator, need to change
Alain Reguera Delgado 46de3c
        in order to keep source file messages consistent with their
Alain Reguera Delgado 46de3c
        localized versions.  In the very specific case of shell
Alain Reguera Delgado 46de3c
        scripts localization, this option takes care of updating the
Alain Reguera Delgado 46de3c
        machine object (MO) file the shell script requires to
Alain Reguera Delgado 46de3c
        displayed translation messages correctly when it is executed.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--delete</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This option unlocalizes source files. When you provide this
Alain Reguera Delgado 46de3c
        option, the localization directory related to source files is
Alain Reguera Delgado 46de3c
        removed from the working copy in conjunction with all portable
Alain Reguera Delgado 46de3c
        objects and machine objects inside it.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <varlistentry>
Alain Reguera Delgado 46de3c
    <term><option>--dont-create-mo</option></term>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This option suppresses machine objects creation when shell
Alain Reguera Delgado 46de3c
        scripts are localized.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </varlistentry>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    </variablelist>
Alain Reguera Delgado 46de3c
    </refsection>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refsection id="scripts-bash-locale-description">
Alain Reguera Delgado 46de3c
    <title>Description</title>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        The localization process is very tied to the source files we
Alain Reguera Delgado 46de3c
        want to provide localized messages for. Inside the working
Alain Reguera Delgado 46de3c
        copy of &TCAR; it is possible to localize XML-based files
Alain Reguera Delgado 46de3c
        (e.g., SVG and Docbook) and programs written in most popular
Alain Reguera Delgado 46de3c
        programming languages (e.g., C, C++, C#, Shell Scripts,
Alain Reguera Delgado 46de3c
        Python, Java, GNU awk, PHP, etc.).
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        The localization process initiates by retriving translatable
Alain Reguera Delgado 46de3c
        strings from source files.  When source files are XML-based
Alain Reguera Delgado 46de3c
        files, the only requisite to retrive translatable strings
Alain Reguera Delgado 46de3c
        correctly is that they be well-formed.  Beyond that, the
Alain Reguera Delgado 46de3c
        <command>xml2po</command> command takes care of everything
Alain Reguera Delgado 46de3c
        else.  When source files are Shell script files, it is
Alain Reguera Delgado 46de3c
        necessary that you previously define what strings inside the
Alain Reguera Delgado 46de3c
        script are considered as translatable strings in order for
Alain Reguera Delgado 46de3c
        <command>xgettext</command> command to retrive them correctly.
Alain Reguera Delgado 46de3c
        To define translatable strings inside shell scripts, you need
Alain Reguera Delgado 46de3c
        to use either <command>gettext</command>,
Alain Reguera Delgado 46de3c
        <command>ngettext</command>, <command>eval_gettext</command>
Alain Reguera Delgado 46de3c
        or <command>eval_ngettext</command> command as it is following
Alain Reguera Delgado 46de3c
        described:
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <itemizedlist>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Use the <command>gettext</command> command to display the
Alain Reguera Delgado 46de3c
        native language translation of a textual message.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    <screen>MESSAGE="`gettext "There is no entry to create."`"</screen>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Use the <command>ngettext</command> command to display the
Alain Reguera Delgado 46de3c
        native language translation of a textual message whose
Alain Reguera Delgado 46de3c
        grammatical form depends on a number.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    <screen>MESSAGE="`ngettext "The following entry will be created" \
Alain Reguera Delgado 46de3c
                   "The following entries will be created" \
Alain Reguera Delgado 46de3c
                   $COUNT`:"</screen>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Use the <command>eval_gettext</command> command to display the
Alain Reguera Delgado 46de3c
        native language translation of a textual message, performing
Alain Reguera Delgado 46de3c
        dollar-substitution on the result.  Note that only shell
Alain Reguera Delgado 46de3c
        variables mentioned in the message will be dollar-substituted
Alain Reguera Delgado 46de3c
        in the result.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    <screen>MESSAGE="`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`"</screen>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Use the <command>eval_ngettext</command> command to display
Alain Reguera Delgado 46de3c
        the native language translation of a textual message whose
Alain Reguera Delgado 46de3c
        grammatical form depends on a number, performing
Alain Reguera Delgado 46de3c
        dollar-substitution on the result.  Note that only shell
Alain Reguera Delgado 46de3c
        variables mentioned in messages will be dollar-substituted in
Alain Reguera Delgado 46de3c
        the result.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    <screen>MESSAGE="`eval_ngettext "The following entry will be created in \\\$LOCATION" \
Alain Reguera Delgado 46de3c
                        "The following entries will be created in \\\$LOCATION" \
Alain Reguera Delgado 46de3c
                        $COUNT`:"</screen>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </itemizedlist>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Once translatable strings are retrived, a portable object
Alain Reguera Delgado 46de3c
        template (POT) file is created for storing them. Later, the
Alain Reguera Delgado 46de3c
        POT file is used to create a portable object (PO). The
Alain Reguera Delgado 46de3c
        portable object is the place where localization itself takes
Alain Reguera Delgado 46de3c
        place, it is the file translators edit to localize messages.
Alain Reguera Delgado 46de3c
        When translatable strings change inside source files, it is
Alain Reguera Delgado 46de3c
        necessary that you update these POT and PO files in order to
Alain Reguera Delgado 46de3c
        keep consistency between source file messages and their
Alain Reguera Delgado 46de3c
        localized versions.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Inside source files, translatable strings are always written
Alain Reguera Delgado 46de3c
        in English language. In order to localize translatable strings
Alain Reguera Delgado 46de3c
        from English language to another language, you need to be sure
Alain Reguera Delgado 46de3c
        the <envar>LANG</envar> environment variable has been already
Alain Reguera Delgado 46de3c
        set to the locale code you want to localize message for or see
Alain Reguera Delgado 46de3c
        them printed out before running the
Alain Reguera Delgado 46de3c
        <function>locale</function> functionality of
Alain Reguera Delgado 46de3c
        <command>centos-art.sh</command> script.  Localizing English
Alain Reguera Delgado 46de3c
        language to itself is not supported.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        To have a list of all locale codes you can have localized
Alain Reguera Delgado 46de3c
        messages for, run the following command: <command>locale -a |
Alain Reguera Delgado 46de3c
        less</command>.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </refsection>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refsection id="scripts-bash-locale-environment">
Alain Reguera Delgado 46de3c
    <title>Function Specific Environment</title>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        ...
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </refsection>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refsection id="scripts-bash-locale-authors">
Alain Reguera Delgado 46de3c
    <title>Authors</title>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        The following people have worked in the
Alain Reguera Delgado 46de3c
        <function>locale</function> functionality:
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    <itemizedlist>
Alain Reguera Delgado 46de3c
    <listitem>
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Alain Reguera Delgado <<ulink url="mailto:alain.reguera@gmail.com">alain.reguera@gmail.com</ulink>>, =COPYRIGHT_YEAR_LIST=
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </listitem>
Alain Reguera Delgado 46de3c
    </itemizedlist>
Alain Reguera Delgado 46de3c
    </refsection>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <refsection id="scripts-bash-locale-licence">
Alain Reguera Delgado 46de3c
    <title>License</title>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        Copyright © =COPYRIGHT_YEAR_LIST= =COPYRIGHT_HOLDER=
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
 
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This program is free software; you can redistribute it and/or
Alain Reguera Delgado 46de3c
        modify it under the terms of the GNU General Public License as
Alain Reguera Delgado 46de3c
        published by the Free Software Foundation; either version 2 of
Alain Reguera Delgado 46de3c
        the License, or (at your option) any later version.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
 
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        This program is distributed in the hope that it will be
Alain Reguera Delgado 46de3c
        useful, but WITHOUT ANY WARRANTY; without even the implied
Alain Reguera Delgado 46de3c
        warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
Alain Reguera Delgado 46de3c
        PURPOSE.  See the GNU General Public License for more details.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
 
Alain Reguera Delgado 46de3c
    <para>
Alain Reguera Delgado 46de3c
        You should have received a copy of the GNU General Public
Alain Reguera Delgado 46de3c
        License along with this program; if not, write to the Free
Alain Reguera Delgado 46de3c
        Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
Alain Reguera Delgado 46de3c
        USA.
Alain Reguera Delgado 46de3c
    </para>
Alain Reguera Delgado 46de3c
    </refsection>
Alain Reguera Delgado 46de3c
Alain Reguera Delgado 46de3c
</refentry>