From 50dae2f43a110dcd97988551098c9838e81997bc Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Oct 21 2010 18:16:56 +0000 Subject: Update render_getActionsTranslations.sh to support =LOCALE= translation marker. - When editing translation templates, you can use the =LOCALE= traslation marker wherever you need to have the locale information of the current translation file the template translation you are editing on represents. When the translation template is rendered, and the final translation file is created, the replacement for the =LOCALE= translation marker is added automatically by centos-art.sh script to the final translation file. The locale information, used as =LOCALE= replacement, is retrived from the translation template's absolute path. If there is no locale information in the translation template's absolute path, centos-art.sh doesn't add any replacement for =LOCALE= translation markers. In other words, the =LOCALE= translation marker is only available for translation templates inside language specific directories. --- diff --git a/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh b/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh index c2f504a..d8623fc 100755 --- a/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh +++ b/Scripts/Bash/Functions/Render/render_getActionsTranslations.sh @@ -72,6 +72,8 @@ function render_getActionsTranslations { local MAJOR_RELEASE='' local MINOR_RELEASE='' local RELEASE_INFO='' + local LOCALES_INFO='' + local LOCALE='' local TRANSLATION='' local FILE='' @@ -157,31 +159,61 @@ function render_getActionsTranslations { # information previously defined. for FILE in $(find $OPTIONVAL/Tpl -name '*.sed');do - # Define translation file. + # Define translation file locale. + LOCALE=$(echo $FILE | sed -r 's!^/.+/Tpl/([a-z]{2}|[a-z]{2}_[A-Z]{2})/.+$!\1!' ) + if [[ $LOCALE =~ '^([a-z]{2}|[a-z]{2}_[A-Z]{2})$' ]];then + + # Define locales translation markers. + LOCALES_INFO=" + # Locale information. + s!=LOCALE=!${LOCALE}!g" + + # Strip opening spaces from locales translation markers + # output lines. + LOCALES_INFO=$(echo "$LOCALES_INFO" | sed 's!^[[:space:]]*!!') + + fi + + # Define absolute path to translation template file. TRANSLATION=$FILE - # Define destination for final file. + # Define absolute path to translation final file. FILE=$(echo $FILE | sed "s!/Tpl!/$RELEASE!") - # Create release-specific directory if it doesn't exist. + # Create release-specific directory, if it doesn't exist. DIRNAME=$(dirname $FILE) if [[ ! -d $DIRNAME ]];then mkdir -p $DIRNAME fi - # Show some verbose about file being processed. + # Output information about files being processed. cli_printMessage $TRANSLATION "AsTranslationLine" cli_printMessage $FILE "AsSavedAsLine" # Add warnning message to final translation file. echo "$MESSAGE" > $FILE - # Add template content to final translation file. + # Add template content to final translation file. cat $TRANSLATION >> $FILE # Add release markers to final translation file. echo "$RELEASE_INFO" >> $FILE + # Add locales markers to final translation file, if they + # have locales information only. + if [[ $LOCALES_INFO != '' ]];then + echo "$LOCALES_INFO" >> $FILE + # Clean up locales information variable to receive + # next value. If we don't clean up the variable here, + # translation files without locale information (e.g., + # progress-first.sed, firstboot-left.sed, etc.) will + # use the locale information of the last translation + # template which does have locale information and we + # don't want that. We want to set locale information + # for each translation template individually. + LOCALES_INFO='' + fi + echo "------------------------------------------------------------" done