Blame Scripts/Modules/Locale/locale.sh

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