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

ce40cb
#!/bin/bash
ce40cb
#
ce40cb
# render_doTranslationMarkersCommons.sh -- This function standardizes
ce40cb
# replacements for common translation markers. Raplacements are
ce40cb
# applied to temporal instances used to produce the 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_doTranslationMarkersCommons {
ce40cb
ce40cb
    # Initialize variables.
ce40cb
    local -a SRC
ce40cb
    local -a DST
ce40cb
    local COUNT=0
ce40cb
ce40cb
    # Define translation markers.
ce40cb
    SRC[0]='=THEME='
ce40cb
    SRC[1]='=COPYRIGHT='
ce40cb
    SRC[2]='=DESCRIPTION='
ce40cb
    SRC[3]='=LICENSE='
ce40cb
    SRC[4]='=NAME='
ce40cb
    SRC[5]='=RELEASE='
ce40cb
    SRC[6]='=URL='
ce40cb
    SRC[7]='=RELEASE='
ce40cb
    SRC[8]='=MAJOR_RELEASE='
ce40cb
    SRC[9]='=MINOR_RELEASE='
ce40cb
    SRC[10]='=URLLOCALE='
ce40cb
ce40cb
    # Define replacements for translation markers.
ce40cb
    DST[0]="$(cli_getThemeName)"
ce40cb
    DST[1]="$(cli_getCopyrightInfo '--copyright')"
ce40cb
    DST[2]="$(cli_getCopyrightInfo '--description')"
ce40cb
    DST[3]="$(cli_getCopyrightInfo '--license')"
ce40cb
    DST[4]="$(cli_getThemeName '--name')"
ce40cb
    DST[5]="$(cli_getThemeName '--release')"
ce40cb
    DST[6]="http://www.centos.org"
ce40cb
    DST[7]="$(cli_getRelease "$FILE")"
ce40cb
    DST[8]="$(cli_getRelease "$FILE" '--major')"
ce40cb
    DST[9]="$(cli_getRelease "$FILE" '--minor')"
ce40cb
    # Define url locale information. We don't want to show locale
ce40cb
    # information inside url for English language. English is the
ce40cb
    # default locale and no locale level is used for it.  However, if
ce40cb
    # we are rendering for a language different from English, the
ce40cb
    # locale level in the url should be present.
ce40cb
    if [[ $(cli_getCurrentLocale) == 'en' ]];then
ce40cb
        DST[10]=''
ce40cb
    else
ce40cb
        DST[10]="$(cli_getCurrentLocale)/"
ce40cb
    fi
ce40cb
ce40cb
    # Apply replacements for translation markers.
ce40cb
    while [[ ${COUNT} -lt ${#SRC[*]} ]];do
ce40cb
ce40cb
        # Use sed to replace translation markers inside the design
ce40cb
        # 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
}