diff --git a/Scripts/Bash/Functions/Render/render_doIdentityTMarkers.sh b/Scripts/Bash/Functions/Render/render_doIdentityTMarkers.sh new file mode 100755 index 0000000..9225574 --- /dev/null +++ b/Scripts/Bash/Functions/Render/render_doIdentityTMarkers.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# render_doIdentityTMarkers.sh -- This function standardizes +# replacements for both specific and common translation markers. This +# function must be called from render_getIdentityDefs.sh function +# (after instance creation and before final file creation). +# Raplacements are applied to temporal instances used to produce the +# final file. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doIdentityTMarkers { + + # Apply specific replacements for specific translation markers. + render_doIdentityTMarkersSpecifics + + # Apply common replacements for common translation markers. + render_doIdentityTMarkersCommons + +} diff --git a/Scripts/Bash/Functions/Render/render_doIdentityTMarkersCommons.sh b/Scripts/Bash/Functions/Render/render_doIdentityTMarkersCommons.sh new file mode 100755 index 0000000..e761196 --- /dev/null +++ b/Scripts/Bash/Functions/Render/render_doIdentityTMarkersCommons.sh @@ -0,0 +1,88 @@ +#!/bin/bash +# +# render_doIdentityTMarkersCommons.sh -- This function standardizes +# replacements for common translation markers. Raplacements are +# applied to temporal instances used to produce the final file. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doIdentityTMarkersCommons { + + # Initialize variables. + local -a SRC + local -a DST + local COUNT=0 + + # Define translation markers. + SRC[0]='=THEME=' + SRC[1]='=COPYRIGHT=' + SRC[2]='=DESCRIPTION=' + SRC[3]='=LICENSE=' + SRC[4]='=NAME=' + SRC[5]='=RELEASE=' + SRC[6]='=URL=' + SRC[7]='=RELEASE=' + SRC[8]='=MAJOR_RELEASE=' + SRC[9]='=MINOR_RELEASE=' + SRC[10]='=URLLOCALE=' + + # Define replacements for translation markers. + DST[0]="$(cli_getThemeName)" + DST[1]="$(cli_getCopyrightInfo '--copyright')" + DST[2]="$(cli_getCopyrightInfo '--description')" + DST[3]="$(cli_getCopyrightInfo '--license')" + DST[4]="$(cli_getThemeName '--name')" + DST[5]="$(cli_getThemeName '--release')" + DST[6]="http://www.centos.org" + DST[7]="$(cli_getRelease "$FILE")" + DST[8]="$(cli_getRelease "$FILE" '--major')" + DST[9]="$(cli_getRelease "$FILE" '--minor')" + # Define url locale information. We don't want to show locale + # information inside url for English language. English is the + # default locale and no locale level is used for it. However, if + # we are rendering for a language different from English, the + # locale level in the url should be present. + if [[ $(cli_getCurrentLocale) == 'en' ]];then + DST[10]='' + else + DST[10]="$(cli_getCurrentLocale)/" + fi + + # Apply replacements for translation markers. + while [[ ${COUNT} -lt ${#SRC[*]} ]];do + + # Use sed to replace translation markers inside the design + # model instance. + sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" ${INSTANCE} + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + + # Unset specific translation markers and specific replacement + # variables in order to clean them up. Otherwise, undesired values + # may ramain from one file to another. + unset SRC + unset DST + +} diff --git a/Scripts/Bash/Functions/Render/render_doIdentityTMarkersSpecifics.sh b/Scripts/Bash/Functions/Render/render_doIdentityTMarkersSpecifics.sh new file mode 100755 index 0000000..7bd66d9 --- /dev/null +++ b/Scripts/Bash/Functions/Render/render_doIdentityTMarkersSpecifics.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# render_doIdentityTMarkersSpecifics.sh -- This function +# standardizes replacements for specific translation markers. +# Raplacements are applied to temporal instances used to produce the +# final file. +# +# Copyright (C) 2009-2011 Alain Reguera Delgado +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +# USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function render_doIdentityTMarkersSpecifics { + + # Initialize variables. + local -a SRC + local -a DST + local COUNT=0 + + # Initialize specific translation markers (SRC) variable, and + # replacement (DST) variable using the appropriate translation + # file as reference. + if [[ -x ${TRANSLATION} ]];then + # Initialize action-specific functions. + . $TRANSLATION + else + cli_printMessage "`eval_gettext "The \\\$TRANSLATION hasn't execution rights."`" 'AsErrorLine' + cli_printMessage "$(caller)" "AsToKnowMoreLine" + fi + + # Execute function to retrive specific translation markers and + # specific replacement values. + eval render_loadConfig + + # Apply specific replacements for specific translation markers. + while [[ ${COUNT} -lt ${#SRC[*]} ]];do + + # Escape the character used as separator inside sed's + # replacement command. + DST[$COUNT]=$(echo ${DST[$COUNT]} | sed -r 's/!/\\!/g' ) + + # Use sed to replace specific translation markers inside the + # design model instance. + sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" $INSTANCE + + # Increment counter. + COUNT=$(($COUNT + 1)) + + done + + # Unset specific translation markers and specific replacement + # variables in order to clean them up. Otherwise, undesired values + # may ramain from one file to another. + unset SRC + unset DST + +} diff --git a/Scripts/Bash/Functions/Render/render_doTranslationMarkers.sh b/Scripts/Bash/Functions/Render/render_doTranslationMarkers.sh deleted file mode 100755 index 37a9e11..0000000 --- a/Scripts/Bash/Functions/Render/render_doTranslationMarkers.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# render_doTranslationMarkers.sh -- This function standardizes -# replacements for both specific and common translation markers. This -# function must be called from render_getIdentityDefs.sh function -# (after instance creation and before final file creation). -# Raplacements are applied to temporal instances used to produce the -# final file. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doTranslationMarkers { - - # Apply specific replacements for specific translation markers. - render_doTranslationMarkersSpecifics - - # Apply common replacements for common translation markers. - render_doTranslationMarkersCommons - -} diff --git a/Scripts/Bash/Functions/Render/render_doTranslationMarkersCommons.sh b/Scripts/Bash/Functions/Render/render_doTranslationMarkersCommons.sh deleted file mode 100755 index 4fd9478..0000000 --- a/Scripts/Bash/Functions/Render/render_doTranslationMarkersCommons.sh +++ /dev/null @@ -1,88 +0,0 @@ -#!/bin/bash -# -# render_doTranslationMarkersCommons.sh -- This function standardizes -# replacements for common translation markers. Raplacements are -# applied to temporal instances used to produce the final file. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doTranslationMarkersCommons { - - # Initialize variables. - local -a SRC - local -a DST - local COUNT=0 - - # Define translation markers. - SRC[0]='=THEME=' - SRC[1]='=COPYRIGHT=' - SRC[2]='=DESCRIPTION=' - SRC[3]='=LICENSE=' - SRC[4]='=NAME=' - SRC[5]='=RELEASE=' - SRC[6]='=URL=' - SRC[7]='=RELEASE=' - SRC[8]='=MAJOR_RELEASE=' - SRC[9]='=MINOR_RELEASE=' - SRC[10]='=URLLOCALE=' - - # Define replacements for translation markers. - DST[0]="$(cli_getThemeName)" - DST[1]="$(cli_getCopyrightInfo '--copyright')" - DST[2]="$(cli_getCopyrightInfo '--description')" - DST[3]="$(cli_getCopyrightInfo '--license')" - DST[4]="$(cli_getThemeName '--name')" - DST[5]="$(cli_getThemeName '--release')" - DST[6]="http://www.centos.org" - DST[7]="$(cli_getRelease "$FILE")" - DST[8]="$(cli_getRelease "$FILE" '--major')" - DST[9]="$(cli_getRelease "$FILE" '--minor')" - # Define url locale information. We don't want to show locale - # information inside url for English language. English is the - # default locale and no locale level is used for it. However, if - # we are rendering for a language different from English, the - # locale level in the url should be present. - if [[ $(cli_getCurrentLocale) == 'en' ]];then - DST[10]='' - else - DST[10]="$(cli_getCurrentLocale)/" - fi - - # Apply replacements for translation markers. - while [[ ${COUNT} -lt ${#SRC[*]} ]];do - - # Use sed to replace translation markers inside the design - # model instance. - sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" ${INSTANCE} - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - - # Unset specific translation markers and specific replacement - # variables in order to clean them up. Otherwise, undesired values - # may ramain from one file to another. - unset SRC - unset DST - -} diff --git a/Scripts/Bash/Functions/Render/render_doTranslationMarkersSpecifics.sh b/Scripts/Bash/Functions/Render/render_doTranslationMarkersSpecifics.sh deleted file mode 100755 index b11126b..0000000 --- a/Scripts/Bash/Functions/Render/render_doTranslationMarkersSpecifics.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# render_doTranslationMarkersSpecifics.sh -- This function -# standardizes replacements for specific translation markers. -# Raplacements are applied to temporal instances used to produce the -# final file. -# -# Copyright (C) 2009-2011 Alain Reguera Delgado -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 -# USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function render_doTranslationMarkersSpecifics { - - # Initialize variables. - local -a SRC - local -a DST - local COUNT=0 - - # Initialize specific translation markers (SRC) variable, and - # replacement (DST) variable using the appropriate translation - # file as reference. - if [[ -x ${TRANSLATION} ]];then - # Initialize action-specific functions. - . $TRANSLATION - else - cli_printMessage "`eval_gettext "The \\\$TRANSLATION hasn't execution rights."`" 'AsErrorLine' - cli_printMessage "$(caller)" "AsToKnowMoreLine" - fi - - # Execute function to retrive specific translation markers and - # specific replacement values. - eval render_loadConfig - - # Apply specific replacements for specific translation markers. - while [[ ${COUNT} -lt ${#SRC[*]} ]];do - - # Escape the character used as separator inside sed's - # replacement command. - DST[$COUNT]=$(echo ${DST[$COUNT]} | sed -r 's/!/\\!/g' ) - - # Use sed to replace specific translation markers inside the - # design model instance. - sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" $INSTANCE - - # Increment counter. - COUNT=$(($COUNT + 1)) - - done - - # Unset specific translation markers and specific replacement - # variables in order to clean them up. Otherwise, undesired values - # may ramain from one file to another. - unset SRC - unset DST - -} diff --git a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh index d21a780..5c09f38 100644 --- a/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh +++ b/Scripts/Bash/Functions/Render/render_getIdentityDefs.sh @@ -338,6 +338,6 @@ function render_getIdentityDefs { cat $TEMPLATE > $INSTANCE # Replace translation markers with appropriate information. - render_doTranslationMarkers + render_doIdentityTMarkers }