Blame Automation/Modules/Locale/locale.sh

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