From 6c620e3339fa5c8c802555c2198bdb22d44d7d81 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jun 19 2011 19:15:36 +0000 Subject: Update `cli_printMessage' functionality: - Add `--as-template-line' option. Update `render' functionality: - Move DOCTYPE verification from `render_doTranslation' to `render_doBaseActions'. - Start using `--as-template-line'. - Rename TEMPLATE_DOCTYPE variable to TEMPLATE_HAS_DOCTYPE. - Perform document validation, only if it has DOCTYPE definition set inside. - Print translation line only when translation files do exist. Otherwise, weh translation files don't exist, don't print translation line to save vertical space. --- diff --git a/Scripts/Functions/Render/render_doBaseActions.sh b/Scripts/Functions/Render/render_doBaseActions.sh index 683e303..9a72201 100755 --- a/Scripts/Functions/Render/render_doBaseActions.sh +++ b/Scripts/Functions/Render/render_doBaseActions.sh @@ -140,28 +140,33 @@ function render_doBaseActions { TRANSLATION=$(dirname $FILE \ | sed -r 's!trunk/(Manuals|Identity)!trunk/Locales/\1!')/$(cli_getCurrentLocale)/messages.po - # Print final location of translation file. - if [[ ! -f "$TRANSLATION" ]];then - cli_printMessage "`gettext "None"`" --as-translation-line - else - cli_printMessage "$TRANSLATION" --as-translation-line - fi - # Define final location of template file. TEMPLATE=${FILE} - # Validate XML-based document before processing it. This - # step is very important in order to detect document - # malformations and warn you about it, so you can correct - # them before processing the document as input. - if [[ -f $TEMPLATE ]];then + # Print action message. + cli_printMessage "$TEMPLATE" --as-template-line + + # Verify design models file existence. We cannot continue + # with out it. + if [[ ! -f $TEMPLATE ]];then + cli_printMessage "`gettext "The template file doesn't exist."`" --as-error-line + fi + + # Verify whether the design model uses DOCTYPE definition + # or not. + egrep '^ /dev/null + local TEMPLATE_HAS_DOCTYPE=$? + + # Validate document before processing it. This step is + # very important in order to detect document malformations + # and warn you about it, so you can correct them before + # processing the document as input. + if [[ $TEMPLATE_HAS_DOCTYPE -eq 0 ]];then cli_printMessage "$TEMPLATE" --as-validating-line xmllint --valid --noent --noout $TEMPLATE if [[ $? -ne 0 ]];then cli_printMessage "`gettext "Validation failed."`" --as-error-line fi - else - cli_printMessage "`gettext "None"`" --as-validating-line fi # Define final location of output directory. diff --git a/Scripts/Functions/Render/render_doTranslation.sh b/Scripts/Functions/Render/render_doTranslation.sh index cb43fa3..7b6db3e 100755 --- a/Scripts/Functions/Render/render_doTranslation.sh +++ b/Scripts/Functions/Render/render_doTranslation.sh @@ -32,17 +32,16 @@ function render_doTranslation { - # Verify existence of DOCTYPE definition inside template. - egrep '^ /dev/null - local TEMPLATE_DOCTYPE=$? - # Verify translation file existence and create template # instance accordingly. if [[ -f ${TRANSLATION} ]];then + # Print final location of translation file. + cli_printMessage "${TRANSLATION}" --as-translation-line + # Create the translated instance of design model based on # whether the template file has DOCTYPE definition or not. - if [[ ${TEMPLATE_DOCTYPE} -eq 0 ]];then + if [[ ${TEMPLATE_HAS_DOCTYPE} -eq 0 ]];then xmllint --valid --noent ${TEMPLATE} \ | xml2po -a -l $(cli_getCurrentLocale) -p ${TRANSLATION} -o ${INSTANCE} - else @@ -57,7 +56,7 @@ function render_doTranslation { else # Create the non-translated instance of design model. - if [[ ${TEMPLATE_DOCTYPE} -eq 0 ]];then + if [[ ${TEMPLATE_HAS_DOCTYPE} -eq 0 ]];then xmllint --valid --noent ${TEMPLATE} > ${INSTANCE} else cp ${TEMPLATE} ${INSTANCE} diff --git a/Scripts/Functions/cli_printMessage.sh b/Scripts/Functions/cli_printMessage.sh index 4847653..c8026a0 100755 --- a/Scripts/Functions/cli_printMessage.sh +++ b/Scripts/Functions/cli_printMessage.sh @@ -125,6 +125,9 @@ function cli_printMessage { cli_printMessage "`gettext "Validating"`: $MESSAGE" ;; + --as-template-line ) + cli_printMessage "`gettext "Template"`: $MESSAGE" + ;; --as-configuration-line ) cli_printMessage "`gettext "Configuration"`: $MESSAGE"