Blame tcar-scripts-locale/Modules/Files/files.sh

Alain Reguera Delgado f23b0d
#!/bin/bash
Alain Reguera Delgado f23b0d
######################################################################
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#   file.sh -- This module sets file-specific information needed by
Alain Reguera Delgado f23b0d
#   localization actions and executes the actions requested through
Alain Reguera Delgado f23b0d
#   the command-line.
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 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
}