Blame Scripts/Modules/Locale/Modules/Files/files.sh

Alain Reguera Delgado f23b0d
#!/bin/bash
Alain Reguera Delgado f23b0d
######################################################################
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado c0ca71
#   tcar - The CentOS Artwork Repository automation tool.
Alain Reguera Delgado c0ca71
#   Copyright © 2014 The CentOS Artwork SIG
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado c0ca71
#   This program is free software; you can redistribute it and/or
Alain Reguera Delgado c0ca71
#   modify it under the terms of the GNU General Public License as
Alain Reguera Delgado c0ca71
#   published by the Free Software Foundation; either version 2 of the
Alain Reguera Delgado c0ca71
#   License, or (at your option) any later version.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado c0ca71
#   This program is distributed in the hope that it will be useful,
Alain Reguera Delgado c0ca71
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado c0ca71
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado c0ca71
#   General Public License for more details.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado c0ca71
#   You should have received a copy of the GNU General Public License
Alain Reguera Delgado c0ca71
#   along with this program; if not, write to the Free Software
Alain Reguera Delgado c0ca71
#   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado c0ca71
#   Alain Reguera Delgado <al@centos.org.cu>
Alain Reguera Delgado c0ca71
#   39 Street No. 4426 Cienfuegos, Cuba.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
######################################################################
Alain Reguera Delgado f23b0d
Alain Reguera Delgado c0ca71
# Set file-specific information needed by localization actions and
Alain Reguera Delgado c0ca71
# executes the actions requested through the command-line.
Alain Reguera Delgado f23b0d
function files {
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define absolute path of argument passed in the command-line.
Alain Reguera Delgado f23b0d
    local RENDER_FROM=$(tcar_checkRepoDirSource "${1}")
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Verify the argument passed in the command-line is a regular
Alain Reguera Delgado f23b0d
    # file.
Alain Reguera Delgado f23b0d
    tcar_checkFiles -ef ${RENDER_FROM}
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Retrieve the file extension of argument provided in the
Alain Reguera Delgado f23b0d
    # command-line.
Alain Reguera Delgado f23b0d
    local RENDER_TYPE=$(echo ${RENDER_FROM} | sed -r 's/.+\.([[:alnum:]]+)$/\1/')
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define location where final content will be stored. This is
Alain Reguera Delgado f23b0d
    # required for producing docbook document that contain relative
Alain Reguera Delgado f23b0d
    # paths inside (e.g., relative calls to image files) correctly.
Alain Reguera Delgado f23b0d
    RENDER_TARGET=$(dirname ${RENDER_FROM})/Final/${TCAR_SCRIPT_LANG_LC}
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define absolute path of directory holding localization files.
Alain Reguera Delgado f23b0d
    local LOCALE_FROM=$(dirname ${RENDER_FROM})/Locales
Alain Reguera Delgado f23b0d
    if [[ ! -d ${LOCALE_FROM} ]];then
Alain Reguera Delgado f23b0d
        mkdir ${LOCALE_FROM}
Alain Reguera Delgado f23b0d
    fi
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define package name written in POT and PO files. This is the
Alain Reguera Delgado f23b0d
    # name of the initialization file you provided as argument to the
Alain Reguera Delgado f23b0d
    # command line to provide localization for.
Alain Reguera Delgado f23b0d
    local PACKAGE_NAME=$(basename ${RENDER_FROM})
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define package version written in POT and PO files. The script
Alain Reguera Delgado f23b0d
    # version is used here.  Modules doesn't have a version by now.
Alain Reguera Delgado f23b0d
    # They share the same version of the centos-art.sh script.
Alain Reguera Delgado f23b0d
    local PACKAGE_VERSION=${TCAR_SCRIPT_VERSION}
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define absolute path to portable and machine objects.
Alain Reguera Delgado f23b0d
    local POT_FILE=$(tcar_getTemporalFile "${PACKAGE_NAME}.pot")
Alain Reguera Delgado f23b0d
    local PO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/${PACKAGE_NAME}.po
Alain Reguera Delgado f23b0d
    local MO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES/${PACKAGE_NAME}.mo
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Execute actions using the variables defined here as reference.
Alain Reguera Delgado f23b0d
    for ACTION in ${ACTIONS};do
Alain Reguera Delgado f23b0d
        tcar_setModuleEnvironment -m "${ACTION}" -t 'child'
Alain Reguera Delgado f23b0d
    done
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
}