Blame tcar-scripts-locale/locale.sh

Alain Reguera Delgado f23b0d
#!/bin/bash
Alain Reguera Delgado f23b0d
######################################################################
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#   locale.sh -- This module standardizes localization inside the
Alain Reguera Delgado f23b0d
#   repository.  The locale module provides three ways of producing
Alain Reguera Delgado f23b0d
#   localization files:
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#       1. Produce localization for one file only (when a regular file
Alain Reguera Delgado f23b0d
#       is provided as argument in the command-line),
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#       2. Produce localization files for all files in the current
Alain Reguera Delgado f23b0d
#       directory you provided in the command-line (when a directory
Alain Reguera Delgado f23b0d
#       is provided as argument), and
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#       3. Produce localization files for all files in the current
Alain Reguera Delgado f23b0d
#       directory recursively (when a directory is provided as
Alain Reguera Delgado f23b0d
#       argument in the command-line and the --recursive option is
Alain Reguera Delgado f23b0d
#       also provided).
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#   Written by:
Alain Reguera Delgado f23b0d
#   * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# Copyright (C) 2009-2013 The CentOS Artwork SIG
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado f23b0d
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado f23b0d
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado f23b0d
# your option) any later version.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado f23b0d
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado f23b0d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado f23b0d
# General Public License for more details.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado f23b0d
# along with this program; if not, write to the Free Software
Alain Reguera Delgado f23b0d
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
######################################################################
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
function locale {
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define flags controlling they way locale module produce
Alain Reguera Delgado f23b0d
    # localization files.
Alain Reguera Delgado f23b0d
    local LOCALE_FLAG_RECURSIVE="false"
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Initialize module's actions.
Alain Reguera Delgado f23b0d
    local ACTIONS=''
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Redefine module's actions based on arguments passed through
Alain Reguera Delgado f23b0d
    # command-line.
Alain Reguera Delgado f23b0d
    locale_getOptions
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Verify the current locale information to avoid English messages
Alain Reguera Delgado f23b0d
    # from being localized to themselves. The English language is used
Alain Reguera Delgado f23b0d
    # as reference to write translatable strings inside the source
Alain Reguera Delgado f23b0d
    # files.
Alain Reguera Delgado f23b0d
    if [[ ${TCAR_SCRIPT_LANG_LC} =~ '^C$' ]];then
Alain Reguera Delgado f23b0d
        tcar_printMessage "`gettext "The C locale cannot be localized to itself."`" --as-error-line
Alain Reguera Delgado f23b0d
    fi
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Process arguments passed to locale module, based on whether they
Alain Reguera Delgado f23b0d
    # are files or directories.
Alain Reguera Delgado f23b0d
    for ARGUMENT in ${TCAR_MODULE_ARGUMENT};do
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
        local ARGUMENT=$(tcar_checkRepoDirSource "${ARGUMENT}")
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
        if [[ -f ${ARGUMENT} ]];then
Alain Reguera Delgado f23b0d
            tcar_setModuleEnvironment -m "files" -t "child" -g "${ARGUMENT}"
Alain Reguera Delgado f23b0d
        elif [[ -d ${ARGUMENT} ]];then
Alain Reguera Delgado f23b0d
            tcar_setModuleEnvironment -m "directories" -t "child" -g "${ARGUMENT}"
Alain Reguera Delgado f23b0d
        else
Alain Reguera Delgado f23b0d
            tcar_printMessage "`gettext "The argument provided isn't valid."`" --as-error-line
Alain Reguera Delgado f23b0d
        fi
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    done
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
}