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

Alain Reguera Delgado f72cfe
#!/bin/bash
Alain Reguera Delgado f72cfe
######################################################################
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
#   file.sh -- This module sets file-specific information needed by
Alain Reguera Delgado f72cfe
#   localization actions and executes the actions requested through
Alain Reguera Delgado f72cfe
#   the command-line.
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 files {
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Define absolute path of argument passed in the command-line.
Alain Reguera Delgado f72cfe
    local RENDER_FROM=$(tcar_checkRepoDirSource "${1}")
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Verify the argument passed in the command-line is a regular
Alain Reguera Delgado f72cfe
    # file.
Alain Reguera Delgado f72cfe
    tcar_checkFiles -ef ${RENDER_FROM}
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Retrieve the file extension of argument provided in the
Alain Reguera Delgado f72cfe
    # command-line.
Alain Reguera Delgado f72cfe
    local RENDER_TYPE=$(echo ${RENDER_FROM} | sed -r 's/.+\.([[:alnum:]]+)$/\1/')
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Define location where final content will be stored. This is
Alain Reguera Delgado f72cfe
    # required for producing docbook document that contain relative
Alain Reguera Delgado f72cfe
    # paths inside (e.g., relative calls to image files) correctly.
Alain Reguera Delgado f72cfe
    RENDER_TARGET=$(dirname ${RENDER_FROM})/Final/${TCAR_SCRIPT_LANG_LC}
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Define absolute path of directory holding localization files.
Alain Reguera Delgado f72cfe
    local LOCALE_FROM=$(dirname ${RENDER_FROM})/Locales
Alain Reguera Delgado f72cfe
    if [[ ! -d ${LOCALE_FROM} ]];then
Alain Reguera Delgado f72cfe
        mkdir ${LOCALE_FROM}
Alain Reguera Delgado f72cfe
    fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Define package name written in POT and PO files. This is the
Alain Reguera Delgado f72cfe
    # name of the initialization file you provided as argument to the
Alain Reguera Delgado f72cfe
    # command line to provide localization for.
Alain Reguera Delgado f72cfe
    local PACKAGE_NAME=$(basename ${RENDER_FROM})
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Define package version written in POT and PO files. The script
Alain Reguera Delgado f72cfe
    # version is used here.  Modules doesn't have a version by now.
Alain Reguera Delgado f72cfe
    # They share the same version of the centos-art.sh script.
Alain Reguera Delgado f72cfe
    local PACKAGE_VERSION=${TCAR_SCRIPT_VERSION}
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Define absolute path to portable and machine objects.
Alain Reguera Delgado f72cfe
    local POT_FILE=$(tcar_getTemporalFile "${PACKAGE_NAME}.pot")
Alain Reguera Delgado f72cfe
    local PO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/${PACKAGE_NAME}.po
Alain Reguera Delgado f72cfe
    local MO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES/${PACKAGE_NAME}.mo
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Execute actions using the variables defined here as reference.
Alain Reguera Delgado f72cfe
    for ACTION in ${ACTIONS};do
Alain Reguera Delgado f72cfe
        tcar_setModuleEnvironment -m "${ACTION}" -t 'child'
Alain Reguera Delgado f72cfe
    done
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
}