Blame Scripts/Bash/Functions/Locale/locale.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# locale.sh -- This function provides internationalization features
878a2b
# for centos-art.sh script through GNU gettext standard processes.
878a2b
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
878a2b
#
878a2b
# This program is free software; you can redistribute it and/or modify
878a2b
# it under the terms of the GNU General Public License as published by
878a2b
# the Free Software Foundation; either version 2 of the License, or (at
878a2b
# your option) any later version.
878a2b
#
878a2b
# This program is distributed in the hope that it will be useful, but
878a2b
# WITHOUT ANY WARRANTY; without even the implied warranty of
878a2b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
878a2b
# General Public License for more details.
878a2b
#
878a2b
# You should have received a copy of the GNU General Public License
878a2b
# along with this program; if not, write to the Free Software
878a2b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
878a2b
#
878a2b
# ----------------------------------------------------------------------
878a2b
# $Id$
878a2b
# ----------------------------------------------------------------------
878a2b
878a2b
function locale {
878a2b
878a2b
    local ACTIONNAMS=''
878a2b
    local ACTIONNAM=''
878a2b
    local ACTIONVAL=''
878a2b
878a2b
    # Initialize machine object flag (`--dont-create-mo').  This flag
878a2b
    # controls whether the centos-art.sh script does create/update
878a2b
    # machine object (MO) files from related portable object (PO)
878a2b
    # files or not. By default, MO files are created.
878a2b
    local FLAG_DONT_CREATE_MO='false'
878a2b
878a2b
    # Define localization (l10n) base directory. This is the place
878a2b
    # where all translation messages are organized in. Translation
878a2b
    # messages are organized herein using the same layout of the
878a2b
    # components they represent under the `trunk/Identity',
8e46f2
    # `trunk/Documentation/Manuals' or `trunk/Scripts' directory
8e46f2
    # structures.  The localization base directory must be used as
8e46f2
    # source location for subversion operations (e.g., status, update,
8e46f2
    # commit, etc.).  Otherwise, it would be difficult to add
8e46f2
    # directory structures that have several levels down from the
8e46f2
    # localization base directory up to the repository (e.g., it is
8e46f2
    # not possible in subversion to add a directory which parent
8e46f2
    # directory hasn't been added to the repository previously.).
a1a636
    L10N_BASEDIR="$(cli_getRepoTLDir)/Locales"
878a2b
878a2b
    # Interpret arguments and options passed through command-line.
878a2b
    locale_getOptions
878a2b
878a2b
    # Redefine positional parameters using ARGUMENTS. At this point,
878a2b
    # option arguments have been removed from ARGUMENTS variable and
878a2b
    # only non-option arguments remain in it. 
878a2b
    eval set -- "${ARGUMENTS}"
878a2b
878a2b
    # Loop through non-option arguments passed to centos-art.sh script
878a2b
    # through its command-line.
878a2b
    for ACTIONVAL in "$@";do
878a2b
878a2b
        # Sanitate non-option argument to be sure it matches the
878a2b
        # directory convenctions stablished by centos-art.sh script
878a2b
        # against source locations in the working copy.
878a2b
        ACTIONVAL=$(cli_checkRepoDirSource "${ACTIONVAL}")
878a2b
878a2b
        # Verify directory passed as non-option argument to be sure it
878a2b
        # supports localization.
b056e1
        locale_isLocalizable "${ACTIONVAL}"
b056e1
        if [[ $? -ne 0 ]];then
878a2b
            cli_printMessage "`gettext "The path provided does not support localization."`" --as-error-line
878a2b
        fi
878a2b
878a2b
        # Define localization working directory using directory passed
878a2b
        # as non-option argument. The localization working directory
878a2b
        # is the place where POT and PO files are stored inside the
878a2b
        # working copy.
878a2b
        L10N_WORKDIR=$(echo "${ACTIONVAL}" \
5e502e
            | sed -r -e "s!trunk/(Identity|Scripts|Documentation)!trunk/Locales/\1!")/$(cli_getCurrentLocale)
878a2b
3a7d50
        # Syncronize changes between repository and working copy. At
3a7d50
        # this point, changes in the repository are merged in the
3a7d50
        # working copy and changes in the working copy committed up to
3a7d50
        # repository.
3a7d50
        ${CLI_NAME} svn --sync "${L10N_WORKDIR}"
3a7d50
878a2b
        # Execute localization actions provided to centos-art.sh
878a2b
        # script through its command-line. Notice that localization
878a2b
        # actions will be executed in the same order they were
878a2b
        # provided in the command-line.
878a2b
        for ACTIONNAM in ${ACTIONNAMS};do
878a2b
            ${ACTIONNAM}
878a2b
        done
878a2b
3a7d50
        # Syncronize changes between repository and working copy. At
3a7d50
        # this point, changes in the repository are merged in the
3a7d50
        # working copy and changes in the working copy committed up to
3a7d50
        # repository.
3a7d50
        ${CLI_NAME} svn --sync "${L10N_WORKDIR}"
878a2b
3a7d50
    done
878a2b
878a2b
}