diff --git a/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh b/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh index 44ec380..34a5be3 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_createStructure.sh @@ -104,7 +104,7 @@ function texinfo_createStructure { svn cp ${FILE} ${DST} --quiet # Expand common translation markers inside target file. - cli_replaceTMarkers ${DST} + cli_expandTMarkers ${DST} # Expand specific translation markers inside target file. sed -r -i -e "s!=MANUAL_NAME=!${MANUAL_NAME}!g" \ diff --git a/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh b/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh index 3750803..858935c 100755 --- a/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh +++ b/Scripts/Functions/Help/Texinfo/texinfo_updateSectionNodes.sh @@ -108,7 +108,7 @@ function texinfo_updateSectionNodes { fi # Expand common translation markers in documentation entry. - cli_replaceTMarkers "${MANUAL_BASEDIR}/$INCL" + cli_expandTMarkers "${MANUAL_BASEDIR}/$INCL" # Replace node, section and concept index definitions already # defined with node, section and concept index translation diff --git a/Scripts/Functions/Locale/locale_updateMessageMetadata.sh b/Scripts/Functions/Locale/locale_updateMessageMetadata.sh index ab5d549..567d3ce 100755 --- a/Scripts/Functions/Locale/locale_updateMessageMetadata.sh +++ b/Scripts/Functions/Locale/locale_updateMessageMetadata.sh @@ -76,7 +76,7 @@ function locale_updateMessageMetadata { sed -i -r "s/PACKAGE/${TEXTDOMAIN}/g" ${FILE} # Expand translation markers inside file. - cli_replaceTMarkers ${FILE} + cli_expandTMarkers ${FILE} # Unset array variables to avoid undesired concatenations. unset SRC diff --git a/Scripts/Functions/Render/Docbook/docbook_prepareStyles.sh b/Scripts/Functions/Render/Docbook/docbook_prepareStyles.sh index 201cb0f..faf8066 100755 --- a/Scripts/Functions/Render/Docbook/docbook_prepareStyles.sh +++ b/Scripts/Functions/Render/Docbook/docbook_prepareStyles.sh @@ -72,7 +72,7 @@ function docbook_prepareStyles { # Expand common translation markers in the common style instance, # if it exists. if [[ -f $STYLE_INSTANCE_COMMON ]];then - cli_replaceTMarkers $STYLE_INSTANCE_COMMON + cli_expandTMarkers $STYLE_INSTANCE_COMMON fi # Expand specific translation markers in final style instance. diff --git a/Scripts/Functions/Render/Svg/svg_convertPngToDm.sh b/Scripts/Functions/Render/Svg/svg_convertPngToDm.sh index ac4ff30..e7bbb94 100755 --- a/Scripts/Functions/Render/Svg/svg_convertPngToDm.sh +++ b/Scripts/Functions/Render/Svg/svg_convertPngToDm.sh @@ -139,7 +139,7 @@ function svg_convertPngToDm { # Expand translation markers. if [[ ${DST} =~ "\.(xml|desktop)$" ]];then - cli_replaceTMarkers "${DST}" + cli_expandTMarkers "${DST}" fi done diff --git a/Scripts/Functions/Render/Svg/svg_convertPngToGrub.sh b/Scripts/Functions/Render/Svg/svg_convertPngToGrub.sh index 5f85ea8..3fc218b 100755 --- a/Scripts/Functions/Render/Svg/svg_convertPngToGrub.sh +++ b/Scripts/Functions/Render/Svg/svg_convertPngToGrub.sh @@ -98,7 +98,7 @@ function svg_convertPngToGrub { # instance. if [[ ! -f $PALETTE_GPL ]];then svn cp ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/grub.gpl ${PALETTE_GPL} - cli_replaceTMarkers ${PALETTE_GPL} + cli_expandTMarkers ${PALETTE_GPL} fi # Define absolute path to PPM palette. The PPM palette is built diff --git a/Scripts/Functions/Render/Svg/svg_convertPngToKsplash.sh b/Scripts/Functions/Render/Svg/svg_convertPngToKsplash.sh index 85503d0..1c3b6bc 100755 --- a/Scripts/Functions/Render/Svg/svg_convertPngToKsplash.sh +++ b/Scripts/Functions/Render/Svg/svg_convertPngToKsplash.sh @@ -74,6 +74,6 @@ function svg_convertPngToKsplash { cp ${SRC[4]} ${DST[4]} # Apply common translation markers to Theme.rc file. - cli_replaceTMarkers "${DST[4]}" + cli_expandTMarkers "${DST[4]}" } diff --git a/Scripts/Functions/Render/Svg/svg_convertPngToSyslinux.sh b/Scripts/Functions/Render/Svg/svg_convertPngToSyslinux.sh index 3da4ae9..c5583a8 100755 --- a/Scripts/Functions/Render/Svg/svg_convertPngToSyslinux.sh +++ b/Scripts/Functions/Render/Svg/svg_convertPngToSyslinux.sh @@ -112,7 +112,7 @@ function svg_convertPngToSyslinux { # instance. if [[ ! -f $PALETTE_GPL ]];then svn cp ${MODEL_BASEDIR}/${FLAG_THEME_MODEL}/Palettes/syslinux.gpl ${PALETTE_GPL} - cli_replaceTMarkers ${PALETTE_GPL} + cli_expandTMarkers ${PALETTE_GPL} fi # Define absolute path to PPM palette. The PPM palette is built diff --git a/Scripts/Functions/Render/render_doBaseActions.sh b/Scripts/Functions/Render/render_doBaseActions.sh index b20a43b..3a88a32 100755 --- a/Scripts/Functions/Render/render_doBaseActions.sh +++ b/Scripts/Functions/Render/render_doBaseActions.sh @@ -223,7 +223,7 @@ function render_doBaseActions { render_doTranslation # Expand translation markers inside design model instance. - cli_replaceTMarkers ${INSTANCE} + cli_expandTMarkers ${INSTANCE} # Perform backend base-rendition. ${RENDER_BACKEND} diff --git a/Scripts/Functions/Tuneup/Shell/shell_doTopComment.sh b/Scripts/Functions/Tuneup/Shell/shell_doTopComment.sh index bcf74fa..86fb03f 100755 --- a/Scripts/Functions/Tuneup/Shell/shell_doTopComment.sh +++ b/Scripts/Functions/Tuneup/Shell/shell_doTopComment.sh @@ -42,7 +42,7 @@ function shell_doTopComment { cli_checkFiles $INSTANCE # Expand translation markers in template instance. - cli_replaceTMarkers $INSTANCE + cli_expandTMarkers $INSTANCE # Apply template instance to file. sed -r -i -f $INSTANCE $FILE diff --git a/Scripts/Functions/Tuneup/Svg/svg_doMetadata.sh b/Scripts/Functions/Tuneup/Svg/svg_doMetadata.sh index 61832dd..525a1f7 100755 --- a/Scripts/Functions/Tuneup/Svg/svg_doMetadata.sh +++ b/Scripts/Functions/Tuneup/Svg/svg_doMetadata.sh @@ -72,7 +72,7 @@ function svg_doMetadata { -e "s!=DATE=!$(date "+%Y-%m-%d")!" $INSTANCE sed -i -r "/=KEYWORDS=/c\\${KEYS}" $INSTANCE sed -i -r 's/>$/>\\/g' $INSTANCE - cli_replaceTMarkers $INSTANCE + cli_expandTMarkers $INSTANCE # Update scalable vector graphic using template instance. sed -i -f $INSTANCE $FILE diff --git a/Scripts/Functions/cli_expandTMarkers.sh b/Scripts/Functions/cli_expandTMarkers.sh new file mode 100755 index 0000000..e5a1042 --- /dev/null +++ b/Scripts/Functions/cli_expandTMarkers.sh @@ -0,0 +1,173 @@ +#!/bin/bash +# +# cli_expandTMarkers.sh -- This function standardizes +# replacements for common translation markers. Raplacements are +# applied to temporal instances used to produce the final file. +# +# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG +# +# 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., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_expandTMarkers { + + # Initialize variables. + local -a SRC + local -a DST + local COUNT=0 + local COUNTSRC=0 + local COUNTDST=0 + local LOCATION='' + + # Define source location on which sed replacements take place. + LOCATION="$1" + + # Verify file source location. + cli_checkFiles $LOCATION + + # Define copyright translation markers. + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LAST=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LIST=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year-list)" + SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-holder)" + + # Define license translation markers. + SRC[((++${#SRC[*]}))]='=LICENSE=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license)" + SRC[((++${#SRC[*]}))]='=LICENSE_URL=' + DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license-url)" + + # Define theme translation markers. + SRC[((++${#SRC[*]}))]='=THEME=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif)" + SRC[((++${#SRC[*]}))]='=THEMENAME=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-name)" + SRC[((++${#SRC[*]}))]='=THEMERELEASE=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-release)" + + # Define release-specific translation markers. + SRC[((++${#SRC[*]}))]='=RELEASE=' + DST[((++${#DST[*]}))]="$FLAG_RELEASEVER" + SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE=' + DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f1)" + SRC[((++${#SRC[*]}))]='=MINOR_RELEASE=' + DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f2)" + + # Define architectures translation markers. + SRC[((++${#SRC[*]}))]='=ARCH=' + DST[((++${#DST[*]}))]="$(cli_getPathComponent $FLAG_BASEARCH --architecture)" + + # Define url translation markers. + SRC[((++${#SRC[*]}))]='=URL=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--home' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_WIKI=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--wiki' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_LISTS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--lists' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_FORUMS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--forums' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_MIRRORS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--mirrors' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_DOCS=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--docs' '--with-locale') + SRC[((++${#SRC[*]}))]='=URL_IRC=' + DST[((++${#DST[*]}))]=$(cli_printUrl '--irc') + + # Define emails translation markers. + SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' + DST[((++${#DST[*]}))]="centos-docs@centos.org" + SRC[((++${#SRC[*]}))]='=MAIL_L10N=' + DST[((++${#DST[*]}))]="centos-l10n@centos.org" + + # Define locale translation markers. + SRC[((++${#SRC[*]}))]='=LOCALE_LL=' + DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')" + SRC[((++${#SRC[*]}))]='=LOCALE=' + DST[((++${#DST[*]}))]="$(cli_getCurrentLocale)" + + # Define domain translation markers for domains. + SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' + if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then + DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')." + else + DST[((++${#DST[*]}))]="" + fi + + # Define repository translation markers. + SRC[((++${#SRC[*]}))]='=REPO_TLDIR=' + DST[((++${#DST[*]}))]="$(cli_getRepoTLDir)" + SRC[((++${#SRC[*]}))]='=REPO_HOME=' + DST[((++${#DST[*]}))]="${HOME}/artwork" + + # Do replacement of nested translation markers. + while [[ $COUNTDST -lt ${#DST[@]} ]];do + + # Verify existence of translation markers. If there is no + # translation marker on replacement, continue with the next + # one in the list. + if [[ ! ${DST[$COUNTDST]} =~ '=[A-Z_]+=' ]];then + # Increment destination counter. + COUNTDST=$(($COUNTDST + 1)) + # The current replacement value doesn't have translation + # marker inside, so skip it and evaluate the next + # replacement value in the list. + continue + fi + + while [[ $COUNTSRC -lt ${#SRC[*]} ]];do + + # Update replacements. + DST[$COUNTDST]=$(echo ${DST[$COUNTDST]} \ + | sed -r "s!${SRC[$COUNTSRC]}!${DST[$COUNTSRC]}!g") + + # Increment source counter. + COUNTSRC=$(($COUNTSRC + 1)) + + done + + # Reset source counter + COUNTSRC=0 + + # Increment destination counter. + COUNTDST=$(($COUNTDST + 1)) + + done + + # 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" ${LOCATION} + + # 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/Functions/cli_replaceTMarkers.sh b/Scripts/Functions/cli_replaceTMarkers.sh deleted file mode 100755 index 18c184d..0000000 --- a/Scripts/Functions/cli_replaceTMarkers.sh +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/bash -# -# cli_replaceTMarkers.sh -- This function standardizes -# replacements for common translation markers. Raplacements are -# applied to temporal instances used to produce the final file. -# -# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG -# -# 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., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_replaceTMarkers { - - # Initialize variables. - local -a SRC - local -a DST - local COUNT=0 - local COUNTSRC=0 - local COUNTDST=0 - local LOCATION='' - - # Define source location on which sed replacements take place. - LOCATION="$1" - - # Verify file source location. - cli_checkFiles $LOCATION - - # Define copyright translation markers. - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LAST=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LIST=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year-list)" - SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-holder)" - - # Define license translation markers. - SRC[((++${#SRC[*]}))]='=LICENSE=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license)" - SRC[((++${#SRC[*]}))]='=LICENSE_URL=' - DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license-url)" - - # Define theme translation markers. - SRC[((++${#SRC[*]}))]='=THEME=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif)" - SRC[((++${#SRC[*]}))]='=THEMENAME=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-name)" - SRC[((++${#SRC[*]}))]='=THEMERELEASE=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-release)" - - # Define release-specific translation markers. - SRC[((++${#SRC[*]}))]='=RELEASE=' - DST[((++${#DST[*]}))]="$FLAG_RELEASEVER" - SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f1)" - SRC[((++${#SRC[*]}))]='=MINOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f2)" - - # Define architectures translation markers. - SRC[((++${#SRC[*]}))]='=ARCH=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $FLAG_BASEARCH --architecture)" - - # Define url translation markers. - SRC[((++${#SRC[*]}))]='=URL=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--home' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_WIKI=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--wiki' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_LISTS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--lists' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_FORUMS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--forums' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_MIRRORS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--mirrors' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_DOCS=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--docs' '--with-locale') - SRC[((++${#SRC[*]}))]='=URL_IRC=' - DST[((++${#DST[*]}))]=$(cli_printUrl '--irc') - - # Define emails translation markers. - SRC[((++${#SRC[*]}))]='=MAIL_DOCS=' - DST[((++${#DST[*]}))]="centos-docs@centos.org" - SRC[((++${#SRC[*]}))]='=MAIL_L10N=' - DST[((++${#DST[*]}))]="centos-l10n@centos.org" - - # Define locale translation markers. - SRC[((++${#SRC[*]}))]='=LOCALE_LL=' - DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')" - SRC[((++${#SRC[*]}))]='=LOCALE=' - DST[((++${#DST[*]}))]="$(cli_getCurrentLocale)" - - # Define domain translation markers for domains. - SRC[((++${#SRC[*]}))]='=DOMAIN_LL=' - if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')." - else - DST[((++${#DST[*]}))]="" - fi - - # Define repository translation markers. - SRC[((++${#SRC[*]}))]='=REPO_TLDIR=' - DST[((++${#DST[*]}))]="$(cli_getRepoTLDir)" - SRC[((++${#SRC[*]}))]='=REPO_HOME=' - DST[((++${#DST[*]}))]="${HOME}/artwork" - - # Do replacement of nested translation markers. - while [[ $COUNTDST -lt ${#DST[@]} ]];do - - # Verify existence of translation markers. If there is no - # translation marker on replacement, continue with the next - # one in the list. - if [[ ! ${DST[$COUNTDST]} =~ '=[A-Z_]+=' ]];then - # Increment destination counter. - COUNTDST=$(($COUNTDST + 1)) - # The current replacement value doesn't have translation - # marker inside, so skip it and evaluate the next - # replacement value in the list. - continue - fi - - while [[ $COUNTSRC -lt ${#SRC[*]} ]];do - - # Update replacements. - DST[$COUNTDST]=$(echo ${DST[$COUNTDST]} \ - | sed -r "s!${SRC[$COUNTSRC]}!${DST[$COUNTSRC]}!g") - - # Increment source counter. - COUNTSRC=$(($COUNTSRC + 1)) - - done - - # Reset source counter - COUNTSRC=0 - - # Increment destination counter. - COUNTDST=$(($COUNTDST + 1)) - - done - - # 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" ${LOCATION} - - # 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 - -}