Blame Scripts/Bash/Functions/Render/render_doTranslationMarkersSpecifics.sh

ce40cb
#!/bin/bash
ce40cb
#
ce40cb
# render_doTranslationMarkersSpecifics.sh -- This function
ce40cb
# standardizes replacements for specific translation markers.
ce40cb
# Raplacements are applied to temporal instances used to produce the
ce40cb
# final file.
ce40cb
#
ce40cb
# Copyright (C) 2009-2011 Alain Reguera Delgado
ce40cb
# 
ce40cb
# This program is free software; you can redistribute it and/or
ce40cb
# modify it under the terms of the GNU General Public License as
ce40cb
# published by the Free Software Foundation; either version 2 of the
ce40cb
# License, or (at your option) any later version.
ce40cb
# 
ce40cb
# This program is distributed in the hope that it will be useful, but
ce40cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
ce40cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
ce40cb
# General Public License for more details.
ce40cb
#
ce40cb
# You should have received a copy of the GNU General Public License
ce40cb
# along with this program; if not, write to the Free Software
ce40cb
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
ce40cb
# USA.
ce40cb
# 
ce40cb
# ----------------------------------------------------------------------
ce40cb
# $Id$
ce40cb
# ----------------------------------------------------------------------
ce40cb
ce40cb
function render_doTranslationMarkersSpecifics {
ce40cb
ce40cb
    # Initialize variables.
ce40cb
    local -a SRC
ce40cb
    local -a DST
ce40cb
    local COUNT=0
ce40cb
ce40cb
    # Initialize specific translation markers (SRC) variable, and
ce40cb
    # replacement (DST) variable using the appropriate translation
ce40cb
    # file as reference.
ce40cb
    if [[ -x ${TRANSLATION} ]];then
ce40cb
        # Initialize action-specific functions.
ce40cb
        . $TRANSLATION
ce40cb
    else
ce40cb
        cli_printMessage "`eval_gettext "The \\\$TRANSLATION hasn't execution rights."`" 'AsErrorLine'
ce40cb
        cli_printMessage "$(caller)" "AsToKnowMoreLine"
ce40cb
    fi
ce40cb
ce40cb
    # Execute function to retrive specific translation markers and
ce40cb
    # specific replacement values.
ce40cb
    eval render_loadConfig
ce40cb
ce40cb
    # Apply specific replacements for specific translation markers.
ce40cb
    while [[ ${COUNT} -lt ${#SRC[*]} ]];do
ce40cb
ce40cb
        # Escape the character used as separator inside sed's
ce40cb
        # replacement command.
ce40cb
        DST[$COUNT]=$(echo ${DST[$COUNT]} | sed -r 's/!/\\!/g' )
ce40cb
ce40cb
        # Use sed to replace specific translation markers inside the
ce40cb
        # design model instance.
ce40cb
        sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" $INSTANCE
ce40cb
ce40cb
        # Increment counter.
ce40cb
        COUNT=$(($COUNT + 1))
ce40cb
ce40cb
    done
ce40cb
ce40cb
    # Unset specific translation markers and specific replacement
ce40cb
    # variables in order to clean them up. Otherwise, undesired values
ce40cb
    # may ramain from one file to another.
ce40cb
    unset SRC
ce40cb
    unset DST
ce40cb
ce40cb
}