From 0fdaadcdb3ff4879f3f21cd649baaba048fb2362 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Oct 07 2013 05:32:32 +0000 Subject: Update centos-art.sh scripts. - Previously, global functions stored inside Scripts/ directory shared localization messages with centos-art.sh script inside Locales/ directory. This update changes the global function scripts to start using their own localization from Scripts/Locales directory. Now each function that requires localization inside Scripts directory has its own localization files inside Scripts/Locales directory. Not all functions require localization messages. For example, the tcar_setModuleEnvironment function is not appropriate to set gettext calls because it is where module environments are created and definitions of TEXTDOMAIN and TEXTDOMAINDIR are set for modules not the function it self. We can't change the name of these variables because they are required by gettext that way. --- diff --git a/Automation/Scripts/tcar_checkFiles.sh b/Automation/Scripts/tcar_checkFiles.sh index f705692..97aa0f0 100755 --- a/Automation/Scripts/tcar_checkFiles.sh +++ b/Automation/Scripts/tcar_checkFiles.sh @@ -32,6 +32,11 @@ function tcar_checkFiles { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + # Initialize local array variables. local -a CONDITION_COMMAND local -a CONDITION_PATTERN diff --git a/Automation/Scripts/tcar_checkRepoDirSource.sh b/Automation/Scripts/tcar_checkRepoDirSource.sh index feb069d..05febd7 100755 --- a/Automation/Scripts/tcar_checkRepoDirSource.sh +++ b/Automation/Scripts/tcar_checkRepoDirSource.sh @@ -41,6 +41,11 @@ function tcar_checkRepoDirSource { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + local LOCATION=${1} # Remove any dot from arguments passed to centos-art.sh script. diff --git a/Automation/Scripts/tcar_getTemporalFile.sh b/Automation/Scripts/tcar_getTemporalFile.sh index 65eae39..08fc9d2 100755 --- a/Automation/Scripts/tcar_getTemporalFile.sh +++ b/Automation/Scripts/tcar_getTemporalFile.sh @@ -29,6 +29,11 @@ function tcar_getTemporalFile { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + # Define base name for temporal file. This is required when svg # instances are created previous to be parsed by inkscape in order # to be exported as png. In such cases .svg file extension is diff --git a/Automation/Scripts/tcar_printCopyrightInfo.sh b/Automation/Scripts/tcar_printCopyrightInfo.sh index 6961c6e..f50c4cd 100755 --- a/Automation/Scripts/tcar_printCopyrightInfo.sh +++ b/Automation/Scripts/tcar_printCopyrightInfo.sh @@ -39,6 +39,11 @@ function tcar_printCopyrightInfo { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + case "${1}" in --license ) diff --git a/Automation/Scripts/tcar_printMessage.sh b/Automation/Scripts/tcar_printMessage.sh index c281e1f..4a35452 100755 --- a/Automation/Scripts/tcar_printMessage.sh +++ b/Automation/Scripts/tcar_printMessage.sh @@ -27,6 +27,11 @@ function tcar_printMessage { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + local MESSAGE="${1}" local FORMAT="${2}" diff --git a/Automation/Scripts/tcar_printVersion.sh b/Automation/Scripts/tcar_printVersion.sh index f435bab..d9c1cda 100755 --- a/Automation/Scripts/tcar_printVersion.sh +++ b/Automation/Scripts/tcar_printVersion.sh @@ -27,6 +27,11 @@ function tcar_printVersion { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + local PROGRAM_NAME=${1:-${TCAR_SCRIPT_NAME}} local YEAR=$(tcar_printCopyrightInfo --year) local HOLDER=$(tcar_printCopyrightInfo --holder) diff --git a/Automation/Scripts/tcar_setModuleArguments.sh b/Automation/Scripts/tcar_setModuleArguments.sh index 69fbe0c..8926cd4 100755 --- a/Automation/Scripts/tcar_setModuleArguments.sh +++ b/Automation/Scripts/tcar_setModuleArguments.sh @@ -45,6 +45,11 @@ function tcar_setModuleArguments { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + local ARGUMENT='' # Fill up arguments global variable with current positional diff --git a/Automation/Scripts/tcar_setModuleEnvironment.sh b/Automation/Scripts/tcar_setModuleEnvironment.sh index 7d30bf8..6057825 100755 --- a/Automation/Scripts/tcar_setModuleEnvironment.sh +++ b/Automation/Scripts/tcar_setModuleEnvironment.sh @@ -48,7 +48,7 @@ function tcar_setModuleEnvironment { # Define default values for module name and type passed from # arguments. - ARG_MODULE_NAME=${ARG_MODULE_NAME:-`gettext "Unknown"`} + ARG_MODULE_NAME=${ARG_MODULE_NAME:-'unknown'} ARG_MODULE_TYPE=${ARG_MODULE_TYPE:-'top-module'} ARG_MODULE_ARGS=${ARG_MODULE_ARGS:-''} @@ -113,6 +113,14 @@ function tcar_setModuleEnvironment { local TCAR_MODULE_INIT_FILE=${TCAR_MODULE_INIT_FILES[${TCAR_MODULE_COUNT}]} tcar_printMessage "TCAR_MODULE_INIT_FILE : ${TCAR_MODULE_INIT_FILE}" --as-debugger-line + # Define module's connection with their localization files. It is + # required that gettext-specific variables be defined locally, in + # order to implement per-module localization. + local TEXTDOMAIN=$(basename ${TCAR_MODULE_INIT_FILE}) + tcar_printMessage "TEXTDOMAIN: ${TEXTDOMAIN}" --as-debugger-line + local TEXTDOMAINDIR=${TCAR_MODULE_DIR_LOCALES} + tcar_printMessage "TEXTDOMAINDIR: ${TEXTDOMAINDIR}" --as-debugger-line + # Increment module's counter just before creating next module's # base directory. TCAR_MODULE_COUNT=$(( ${TCAR_MODULE_COUNT} + 1 )) @@ -130,11 +138,11 @@ function tcar_setModuleEnvironment { tcar_setModuleEnvironmentScripts # Execute module's initialization script. - tcar_printMessage "`gettext "Opening module"`: ${TCAR_MODULE_NAME} ${TCAR_MODULE_ARGUMENT}" --as-debugger-line + tcar_printMessage "=========================>: ${TCAR_MODULE_NAME} ${TCAR_MODULE_ARGUMENT}" --as-debugger-line ${TCAR_MODULE_NAME} ${TCAR_MODULE_ARGUMENT} # Unset module-specific environment. - tcar_printMessage "`gettext "Closing module"`: ${TCAR_MODULE_NAME}" --as-debugger-line + tcar_printMessage "<=========================: ${TCAR_MODULE_NAME}" --as-debugger-line tcar_unsetModuleEnvironment # Decrement module counter just after unset unused module @@ -144,7 +152,6 @@ function tcar_setModuleEnvironment { # Unset array and non-array variables used in this function. if [[ ${TCAR_MODULE_COUNT} -eq 0 ]];then - tcar_printMessage "`gettext "Closing variables"`: " --as-debugger-line unset TCAR_MODULE_NAMES unset TCAR_MODULE_BASEDIRS unset TCAR_MODULE_DIRS diff --git a/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh b/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh index de890c2..52bff23 100755 --- a/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh +++ b/Automation/Scripts/tcar_setModuleEnvironmentScripts.sh @@ -28,6 +28,11 @@ function tcar_setModuleEnvironmentScripts { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + # Define the pattern used to retrieve function names from function # files. local FUNCTION_PATTERN="^function[[:space:]]+${TCAR_MODULE_NAME}(_[[:alnum:]]+)?[[:space:]]+{[[:space:]]*$" diff --git a/Automation/Scripts/tcar_unsetModuleEnvironment.sh b/Automation/Scripts/tcar_unsetModuleEnvironment.sh index a5e9c4a..6a77d98 100755 --- a/Automation/Scripts/tcar_unsetModuleEnvironment.sh +++ b/Automation/Scripts/tcar_unsetModuleEnvironment.sh @@ -27,6 +27,11 @@ function tcar_unsetModuleEnvironment { + # Define gettext-specific variables locally, to provide + # per-function localization. + local TEXTDOMAIN="${FUNCNAME}.sh" + local TEXTDOMAINDIR="${TCAR_SCRIPT_BASEDIR}/Scripts/Locales" + # Verify suffix value used to retrieve function files. if [[ -z ${TCAR_MODULE_NAME} ]];then tcar_printMessage "`gettext "The export id was not provided."`" --as-error-line