diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Delete/delete.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Delete/delete.sh new file mode 100755 index 0000000..162b823 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Delete/delete.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +function delete { + + local TRANSLATION='' + + for TRANSLATION in ${TRANSLATIONS[*]};do + tcar_printMessage "${TRANSLATION}" --as-deleting-line + tcar_checkFiles -ef ${TRANSLATION} + /bin/rm ${TRANSLATION} + done + + +} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Edit/edit.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Edit/edit.sh new file mode 100755 index 0000000..3951411 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Edit/edit.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +function edit { + + local TRANSLATION='' + + for TRANSLATION in ${TRANSLATIONS[*]};do + tcar_printMessage "${TRANSLATION}" --as-editing-line + tcar_checkFiles -ef "${TRANSLATION}" + ${TCAR_USER_EDITOR} ${TRANSLATION} + done + +} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Asciidoc/asciidoc.sh new file mode 100755 index 0000000..ab82636 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Asciidoc/asciidoc.sh @@ -0,0 +1,57 @@ +#!/bin/bash +###################################################################### +# +# Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh -- This +# module takes one or more asciidoc files as source and produces +# docbook temporal files for one of them. The docbook temporal files +# are used to create portable objects to different locale +# information. +# +# Written by: +# * Alain Reguera Delgado , 2013 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function asciidoc { + + local ASCIIDOC_FILE='' + + for ASCIIDOC_FILE in ${SOURCES[*]};do + + # Define POT's default location using the source file as + # reference. The portable object template is + # locale-independent so it must be out of locale-specific + # directories. + local POT_FILE=${ASCIIDOC_FILE}.pot + + tcar_printMessage "${POT_FILE}" --as-creating-line + + local DOCBOOK_FILE=$(tcar_getTemporalFile $(basename ${ASCIIDOC_FILE})).docbook + + asciidoc_convertAsciidocToDocbook + + locale_convertXmlToPot "${DOCBOOK_FILE}" "${POT_FILE}" + + # Verify, initialize or merge portable objects from portable + # object templates. + locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" + + done + +} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Asciidoc/asciidoc_convertAsciidocToDocbook.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Asciidoc/asciidoc_convertAsciidocToDocbook.sh new file mode 100755 index 0000000..cf6c1e3 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Asciidoc/asciidoc_convertAsciidocToDocbook.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +function asciidoc_convertAsciidocToDocbook { + + /usr/bin/asciidoc --backend="docbook" --doctype="${RENDER_FLOW}" \ + --out-file=${DOCBOOK_FILE} ${ASCIIDOC_FILE} + +} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Sh/sh.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Sh/sh.sh new file mode 100755 index 0000000..5b10d58 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Sh/sh.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# Modules/Locale/Modules/Update/Modules/Sh/sh.sh -- This function +# parses shell scripts source files under action value and retrieves +# translatable strings in order to creates/updates both the portable +# object template (.pot) and the portable object (.po) related. +# +# Written by: +# * Alain Reguera Delgado +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function sh { + + # Print action message. + tcar_printMessage "${POT_FILE}" --as-updating-line + + # Retrieve translatable strings from shell script files and create + # the portable object template (.pot) from them. + xgettext --output=${POT_FILE} --width=70 \ + --package-name=${TCAR_SCRIPT_NAME} \ + --package-version=${TCAR_SCRIPT_VERSION} \ + --msgid-bugs-address="centos-l10n-${TCAR_SCRIPT_LANG_LL}@centos.org.cu" \ + --copyright-holder="$(tcar_printCopyrightInfo --holder)" \ + --sort-by-file ${SOURCES[*]} + + # Verify, initialize or update portable objects from portable + # object templates. + locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" + + # At this point some changes might be realized inside the PO file, + # so we need to update the related MO file based on recently + # updated PO files here in order for `centos-art.sh' script to + # print out the most up to date revision of localized messages. + # Notice that this is required only if we were localizing shell + # scripts. + locale_convertPoToMo + +} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Svg/svg.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Svg/svg.sh new file mode 100755 index 0000000..86ae615 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Svg/svg.sh @@ -0,0 +1,57 @@ +#!/bin/bash +###################################################################### +# +# Modules/Locale/Modules/Svg/svg.sh -- This function parses +# XML-based files (e.g., scalable vector graphics), retrieves +# translatable strings and creates/update gettext portable objects. +# +# Written by: +# * Alain Reguera Delgado +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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. +# +###################################################################### + +function svg { + + local SVG_FILE='' + + for SVG_FILE in ${SOURCES[*]};do + + # Define POT's default location using the source file as + # reference. The portable object template is + # locale-independent so it must be out of locale-specific + # directories. + local POT_FILE=${SVG_FILE}.pot + + tcar_printMessage "${POT_FILE}" --as-creating-line + + local SVG_INSTANCE=$(tcar_getTemporalFile $(basename ${SVG_FILE})) + + svg_createSvgInstance + + locale_convertXmlToPot "${SVG_INSTANCE}" "${POT_FILE}" + + # Verify, initialize or merge portable objects from portable + # object templates. + locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" + + done + + + +} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Svg/svg_createSvgInstance.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Svg/svg_createSvgInstance.sh new file mode 100755 index 0000000..e8b4089 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/Modules/Svg/svg_createSvgInstance.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +function svg_createSvgInstance { + + if [[ $(file -b -i ${SVG_FILE}) =~ '^application/x-gzip$' ]];then + /bin/zcat ${SVG_FILE} > ${SVG_INSTANCE} + else + /bin/cat ${SVG_FILE} > ${SVG_INSTANCE} + fi + +} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/update.conf.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/update.conf.sh new file mode 100755 index 0000000..bd6d681 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/update.conf.sh @@ -0,0 +1,2 @@ +#!/bin/bash +declare -x TCAR_SCRIPT_MODULES_BASEDIR=${MODULE_DIR_MODULES} diff --git a/Automation/Modules/Locale/Modules/Actions/Modules/Update/update.sh b/Automation/Modules/Locale/Modules/Actions/Modules/Update/update.sh new file mode 100755 index 0000000..a611c4e --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/Modules/Update/update.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +function update { + + tcar_setModuleEnvironment "${RENDER_TYPE}" "${@}" + +} diff --git a/Automation/Modules/Locale/Modules/Actions/actions.conf.sh b/Automation/Modules/Locale/Modules/Actions/actions.conf.sh new file mode 100755 index 0000000..9253d8b --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/actions.conf.sh @@ -0,0 +1,2 @@ +#!/bin/bash +declare -x TCAR_SCRIPT_MODULES_BASEDIR=${MODULE_DIR_MODULES} diff --git a/Automation/Modules/Locale/Modules/Actions/actions.sh b/Automation/Modules/Locale/Modules/Actions/actions.sh new file mode 100755 index 0000000..4ca2b1f --- /dev/null +++ b/Automation/Modules/Locale/Modules/Actions/actions.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +function actions { + + local LOCALE_ACTION='' + + for LOCALE_ACTION in ${LOCALE_ACTIONS};do + tcar_setModuleEnvironment "${LOCALE_ACTION}" "${@}" + done + +} diff --git a/Automation/Modules/Locale/Modules/Delete/delete.sh b/Automation/Modules/Locale/Modules/Delete/delete.sh deleted file mode 100755 index 162b823..0000000 --- a/Automation/Modules/Locale/Modules/Delete/delete.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -function delete { - - local TRANSLATION='' - - for TRANSLATION in ${TRANSLATIONS[*]};do - tcar_printMessage "${TRANSLATION}" --as-deleting-line - tcar_checkFiles -ef ${TRANSLATION} - /bin/rm ${TRANSLATION} - done - - -} diff --git a/Automation/Modules/Locale/Modules/Directory/directory.sh b/Automation/Modules/Locale/Modules/Directory/directory.sh new file mode 100755 index 0000000..3819940 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Directory/directory.sh @@ -0,0 +1,26 @@ +#!/bin/bash +function directory { + + # Sanitate non-option arguments to be sure they match the + # directory conventions established by centos-art.sh script + # against source directory locations in the working copy. + local DIRECTORY=$(tcar_checkRepoDirSource ${1}) + + # Retrieve list of configuration files from directory. + local CONFIGURATIONS=$(tcar_getFilesList ${DIRECTORY} \ + --pattern=".+/.+\.conf$" --type="f") + + # Verify non-option arguments passed to centos-art.sh + # command-line. The path provided as argument must exist in the + # repository. Otherwise, it would be possible to create arbitrary + # directories inside the repository without any meaning. In order + # to be sure all required directories are available in the + # repository it is necessary use the prepare functionality. + tcar_checkFiles -ef ${CONFIGURATIONS} + + # Process each configuration file. + for CONFIGURATION in ${CONFIGURATIONS};do + directory_getConfiguration "${@}" + done + +} diff --git a/Automation/Modules/Locale/Modules/Directory/directory_getConfiguration.sh b/Automation/Modules/Locale/Modules/Directory/directory_getConfiguration.sh new file mode 100755 index 0000000..432001c --- /dev/null +++ b/Automation/Modules/Locale/Modules/Directory/directory_getConfiguration.sh @@ -0,0 +1,85 @@ +#!/bin/bash + +function directory_getConfiguration { + + local SECTION='' + local -a SECTIONS + + # Define motif-specific environment variables, based on + # configuration file path. These variables might save + # configuration file writers from typing motif-specific + # information when they produce motif-specific content. These + # variables will be empty if the configuration file isn't inside + # a motif-specific directory structure. + MOTIF=$(tcar_getPathComponent ${CONFIGURATION} --motif) + MOTIF_NAME=$(tcar_getPathComponent ${CONFIGURATION} --motif-name) + MOTIF_VERSION=$(tcar_getPathComponent ${CONFIGURATION} --motif-version) + + # Use arrays to store section names. This make possible to make + # use of post-rendition and last-rendition concepts. Otherwise it + # would be difficult to predict information about sections inside + # deeper environments. + for SECTION in $(tcar_getConfigSectionNames "${CONFIGURATION}" \ + | egrep ${TCAR_FLAG_FILTER});do + SECTIONS[((++${#SECTIONS[*]}))]="${SECTION}" + done + + local COUNTER=0 + + while [[ ${COUNTER} -lt ${#SECTIONS[*]} ]];do + + # Initialize array variables locally. + local -a TRANSLATIONS + local -a SOURCES + + local SECTION=${SECTIONS[${COUNTER}]} + + local RENDER_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-from") + for SOURCE in ${RENDER_FROM};do + if [[ ${SOURCE} =~ "^/" ]];then + SOURCES[((++${#SOURCES[*]}))]=${SOURCE} + else + SOURCES[((++${#SOURCES[*]}))]=$(dirname ${CONFIGURATION})/${SOURCE} + fi + done + + local RENDER_TYPE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-type") + if [[ -z ${RENDER_TYPE} ]];then + RENDER_TYPE=$(echo ${SOURCES[0]} | sed -r 's/.+\.([[:alpha:]]+)$/\1/') + fi + + local LOCALE_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "locale-from") + for TRANSLATION in ${LOCALE_FROM};do + if [[ ${TRANSLATION} =~ "^/" ]];then + TRANSLATIONS[((++${#TRANSLATIONS[*]}))]=${TRANSLATION} + else + TRANSLATIONS[((++${#TRANSLATIONS[*]}))]=$(dirname ${CONFIGURATION})/${TRANSLATION} + fi + done + + RENDER_FLOW=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-flow") + if [[ -z ${RENDER_FLOW} ]];then + RENDER_FLOW='article' + fi + + PO_FILE=${TRANSLATIONS[0]} + + # Initialize locale's actions module. + tcar_setModuleEnvironment "actions" "${@}" + + # Increment section's counter. + COUNTER=$(( ${COUNTER} + 1 )) + + # Reset array variable to avoid undesired concatenations + # between sections blocks. + unset TRANSLATIONS + unset SOURCES + + done + + # Reset array variables and their counters to avoid undesired + # concatenations between configuration files. + unset COUNTER + unset SECTIONS + +} diff --git a/Automation/Modules/Locale/Modules/Edit/edit.sh b/Automation/Modules/Locale/Modules/Edit/edit.sh deleted file mode 100755 index 3951411..0000000 --- a/Automation/Modules/Locale/Modules/Edit/edit.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -function edit { - - local TRANSLATION='' - - for TRANSLATION in ${TRANSLATIONS[*]};do - tcar_printMessage "${TRANSLATION}" --as-editing-line - tcar_checkFiles -ef "${TRANSLATION}" - ${TCAR_USER_EDITOR} ${TRANSLATION} - done - -} diff --git a/Automation/Modules/Locale/Modules/File/file.sh b/Automation/Modules/Locale/Modules/File/file.sh new file mode 100755 index 0000000..3b18fe0 --- /dev/null +++ b/Automation/Modules/Locale/Modules/File/file.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +function file { + + local FILE=$(tcar_checkRepoDirSource "${1}") + + tcar_checkFiles -ef ${FILE} + + local FILE_NAME="$(basename ${FILE})" + + local FILE_EXTENSION=$(echo ${FILE} | sed -r 's/.+\.([[:alnum:]]+)$/\1/') + + local DIRECTORY=$(dirname ${FILE}) + + local RENDER_FROM=$(tcar_getFilesList ${DIRECTORY} \ + --pattern="^.+/.+\.${FILE_EXTENSION}$" --type="f") + + local LOCALE_FROM=${DIRECTORY}/Locales + + local POT_FILE=${LOCALE_FROM}/${FILE_NAME}.pot + local PO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/${FILE_NAME}.po + local MO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES/${FILE_NAME}.mo + + # The locale's action modules relay in specific environment + # variables for working. From this point on we set such + # variable's name convention, using the information set above. + file_getConfiguration + +} diff --git a/Automation/Modules/Locale/Modules/File/file_getConfiguration.sh b/Automation/Modules/Locale/Modules/File/file_getConfiguration.sh new file mode 100755 index 0000000..176d14d --- /dev/null +++ b/Automation/Modules/Locale/Modules/File/file_getConfiguration.sh @@ -0,0 +1,21 @@ +#!/bin/bash +function file_getConfiguration { + + # Define the rendition do you want to perform. + local RENDER_TYPE=${FILE_EXTENSION} + + # Define the translation file you want to use. + local -a TRANSLATIONS + TRANSLATIONS[0]=${PO_FILE} + + # Define translation file. This is from which translatable strings + # will be retrieved. + local -a SOURCES + for SOURCE in ${RENDER_FROM};do + SOURCES[((++${#SOURCES[*]}))]=${SOURCE} + done + + # Process configuration variables through locale's actions module. + tcar_setModuleEnvironment "actions" "${@}" + +} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh deleted file mode 100755 index ab82636..0000000 --- a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -###################################################################### -# -# Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh -- This -# module takes one or more asciidoc files as source and produces -# docbook temporal files for one of them. The docbook temporal files -# are used to create portable objects to different locale -# information. -# -# Written by: -# * Alain Reguera Delgado , 2013 -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function asciidoc { - - local ASCIIDOC_FILE='' - - for ASCIIDOC_FILE in ${SOURCES[*]};do - - # Define POT's default location using the source file as - # reference. The portable object template is - # locale-independent so it must be out of locale-specific - # directories. - local POT_FILE=${ASCIIDOC_FILE}.pot - - tcar_printMessage "${POT_FILE}" --as-creating-line - - local DOCBOOK_FILE=$(tcar_getTemporalFile $(basename ${ASCIIDOC_FILE})).docbook - - asciidoc_convertAsciidocToDocbook - - locale_convertXmlToPot "${DOCBOOK_FILE}" "${POT_FILE}" - - # Verify, initialize or merge portable objects from portable - # object templates. - locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" - - done - -} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_convertAsciidocToDocbook.sh b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_convertAsciidocToDocbook.sh deleted file mode 100755 index cf6c1e3..0000000 --- a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_convertAsciidocToDocbook.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -function asciidoc_convertAsciidocToDocbook { - - /usr/bin/asciidoc --backend="docbook" --doctype="${RENDER_FLOW}" \ - --out-file=${DOCBOOK_FILE} ${ASCIIDOC_FILE} - -} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh b/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh deleted file mode 100755 index 5b10d58..0000000 --- a/Automation/Modules/Locale/Modules/Update/Modules/Sh/sh.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# -# Modules/Locale/Modules/Update/Modules/Sh/sh.sh -- This function -# parses shell scripts source files under action value and retrieves -# translatable strings in order to creates/updates both the portable -# object template (.pot) and the portable object (.po) related. -# -# Written by: -# * Alain Reguera Delgado -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function sh { - - # Print action message. - tcar_printMessage "${POT_FILE}" --as-updating-line - - # Retrieve translatable strings from shell script files and create - # the portable object template (.pot) from them. - xgettext --output=${POT_FILE} --width=70 \ - --package-name=${TCAR_SCRIPT_NAME} \ - --package-version=${TCAR_SCRIPT_VERSION} \ - --msgid-bugs-address="centos-l10n-${TCAR_SCRIPT_LANG_LL}@centos.org.cu" \ - --copyright-holder="$(tcar_printCopyrightInfo --holder)" \ - --sort-by-file ${SOURCES[*]} - - # Verify, initialize or update portable objects from portable - # object templates. - locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" - - # At this point some changes might be realized inside the PO file, - # so we need to update the related MO file based on recently - # updated PO files here in order for `centos-art.sh' script to - # print out the most up to date revision of localized messages. - # Notice that this is required only if we were localizing shell - # scripts. - locale_convertPoToMo - -} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh deleted file mode 100755 index 86ae615..0000000 --- a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/bash -###################################################################### -# -# Modules/Locale/Modules/Svg/svg.sh -- This function parses -# XML-based files (e.g., scalable vector graphics), retrieves -# translatable strings and creates/update gettext portable objects. -# -# Written by: -# * Alain Reguera Delgado -# -# Copyright (C) 2009-2013 The CentOS Project -# -# 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. -# -###################################################################### - -function svg { - - local SVG_FILE='' - - for SVG_FILE in ${SOURCES[*]};do - - # Define POT's default location using the source file as - # reference. The portable object template is - # locale-independent so it must be out of locale-specific - # directories. - local POT_FILE=${SVG_FILE}.pot - - tcar_printMessage "${POT_FILE}" --as-creating-line - - local SVG_INSTANCE=$(tcar_getTemporalFile $(basename ${SVG_FILE})) - - svg_createSvgInstance - - locale_convertXmlToPot "${SVG_INSTANCE}" "${POT_FILE}" - - # Verify, initialize or merge portable objects from portable - # object templates. - locale_convertPotToPo "${POT_FILE}" "${PO_FILE}" - - done - - - -} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg_createSvgInstance.sh b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg_createSvgInstance.sh deleted file mode 100755 index e8b4089..0000000 --- a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg_createSvgInstance.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash - -function svg_createSvgInstance { - - if [[ $(file -b -i ${SVG_FILE}) =~ '^application/x-gzip$' ]];then - /bin/zcat ${SVG_FILE} > ${SVG_INSTANCE} - else - /bin/cat ${SVG_FILE} > ${SVG_INSTANCE} - fi - -} diff --git a/Automation/Modules/Locale/Modules/Update/update.conf.sh b/Automation/Modules/Locale/Modules/Update/update.conf.sh deleted file mode 100755 index bd6d681..0000000 --- a/Automation/Modules/Locale/Modules/Update/update.conf.sh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -declare -x TCAR_SCRIPT_MODULES_BASEDIR=${MODULE_DIR_MODULES} diff --git a/Automation/Modules/Locale/Modules/Update/update.sh b/Automation/Modules/Locale/Modules/Update/update.sh deleted file mode 100755 index a611c4e..0000000 --- a/Automation/Modules/Locale/Modules/Update/update.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -function update { - - tcar_setModuleEnvironment "${RENDER_TYPE}" "${@}" - -} diff --git a/Automation/Modules/Locale/locale.conf.sh b/Automation/Modules/Locale/locale.conf.sh index b7589f3..9bd3460 100755 --- a/Automation/Modules/Locale/locale.conf.sh +++ b/Automation/Modules/Locale/locale.conf.sh @@ -1,3 +1,4 @@ #!/bin/bash -declare -x LOCALE_ACTIONS='' -declare -x TCAR_SCRIPT_MODULES_BASEDIR=${MODULE_DIR_MODULES} +declare -x MODULE_VERSION='0.1' +declare -x LOCALE_ACTIONS='' +declare -x TCAR_SCRIPT_MODULES_BASEDIR=${MODULE_DIR_MODULES} diff --git a/Automation/Modules/Locale/locale.sh b/Automation/Modules/Locale/locale.sh index 9f639c1..5d977ce 100755 --- a/Automation/Modules/Locale/locale.sh +++ b/Automation/Modules/Locale/locale.sh @@ -42,14 +42,14 @@ function locale { tcar_printMessage "`gettext "The English language cannot be localized to itself."`" --as-error-line fi - # Process arguments based on whether they are files or - # directories. + # Process arguments passed to locale module, based on whether they + # are files or directories. for ARGUMENT in ${@};do ARGUMENT=$(tcar_checkRepoDirSource "${ARGUMENT}") if [[ -f ${ARGUMENT} ]];then - locale_setFileProcessing "${ARGUMENT}" + tcar_setModuleEnvironment "file" "${@}" elif [[ -d ${ARGUMENT} ]];then - locale_setDirProcessing "${ARGUMENT}" + tcar_setModuleEnvironment "directory" "${@}" else tcar_printMessage "`gettext "The argument provided isn't valid."`" --as-error-line fi diff --git a/Automation/Modules/Locale/locale_getOptions.sh b/Automation/Modules/Locale/locale_getOptions.sh index 9eb3d34..d72a350 100755 --- a/Automation/Modules/Locale/locale_getOptions.sh +++ b/Automation/Modules/Locale/locale_getOptions.sh @@ -29,10 +29,10 @@ function locale_getOptions { # Define short options we want to support. - local ARGSS="h" + local ARGSS="h,v" # Define long options we want to support. - local ARGSL="help,filter:,update,edit,delete" + local ARGSL="help,version,filter:,update,edit,delete" # Redefine arguments using getopt(1) command parser. tcar_setArguments "${@}" @@ -47,7 +47,10 @@ function locale_getOptions { -h | --help ) tcar_printHelp - exit + ;; + + -v | --version ) + tcar_printVersion ;; --filter ) diff --git a/Automation/Modules/Locale/locale_setDirProcessing.sh b/Automation/Modules/Locale/locale_setDirProcessing.sh deleted file mode 100755 index 4bcc369..0000000 --- a/Automation/Modules/Locale/locale_setDirProcessing.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -function locale_setDirProcessing { - - # Sanitate non-option arguments to be sure they match the - # directory conventions established by centos-art.sh script - # against source directory locations in the working copy. - local DIRECTORY=$(tcar_checkRepoDirSource ${1}) - - # Retrieve list of configuration files from directory. - local CONFIGURATIONS=$(tcar_getFilesList ${DIRECTORY} \ - --pattern=".+/.+\.conf$" --type="f") - - # Verify non-option arguments passed to centos-art.sh - # command-line. The path provided as argument must exist in the - # repository. Otherwise, it would be possible to create arbitrary - # directories inside the repository without any meaning. In order - # to be sure all required directories are available in the - # repository it is necessary use the prepare functionality. - tcar_checkFiles -ef ${CONFIGURATIONS} - - # Process each configuration file. - for CONFIGURATION in ${CONFIGURATIONS};do - locale_setLocaleType "${@}" - done - -} diff --git a/Automation/Modules/Locale/locale_setFileProcessing.sh b/Automation/Modules/Locale/locale_setFileProcessing.sh deleted file mode 100755 index 1ff2c70..0000000 --- a/Automation/Modules/Locale/locale_setFileProcessing.sh +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/bash -function locale_setFileProcessing { - - local FILE=$(tcar_checkRepoDirSource "${1}") - - local FILE_NAME="$(basename ${FILE})" - - local FILE_EXTENSION=$(echo ${FILE} | sed -r 's/.+\.([[:alnum:]]+)$/\1/') - - local DIRECTORY=$(dirname ${FILE}) - - local RENDER_FROM=$(tcar_getFilesList ${DIRECTORY} \ - --pattern="^.+/.+\.${FILE_EXTENSION}$" --type="f") - - local LOCALE_FROM=${DIRECTORY}/Locales - - local POT_FILE=${LOCALE_FROM}/${FILE_NAME}.pot - local PO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/${FILE_NAME}.po - local MO_FILE=${LOCALE_FROM}/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES/${FILE_NAME}.mo - - # The locale's modules require specific environment variables we - # need to define here in order for such modules to work as - # expected. From this point on we set such variables using the - # information set above. - - local RENDER_TYPE=${FILE_EXTENSION} - - local -a TRANSLATIONS - TRANSLATIONS[0]=${PO_FILE} - - for SOURCE in ${RENDER_FROM};do - SOURCES[((++${#SOURCES[*]}))]=${SOURCE} - done - - # Initialize locale's action modules. - for LOCALE_ACTION in ${LOCALE_ACTIONS};do - tcar_setModuleEnvironment "${LOCALE_ACTION}" "${@}" - done - -} diff --git a/Automation/Modules/Locale/locale_setLocaleType.sh b/Automation/Modules/Locale/locale_setLocaleType.sh deleted file mode 100755 index 77c4190..0000000 --- a/Automation/Modules/Locale/locale_setLocaleType.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -function locale_setLocaleType { - - local SECTION='' - local -a SECTIONS - - # Define motif-specific environment variables, based on - # configuration file path. These variables might save - # configuration file writers from typing motif-specific - # information when they produce motif-specific content. These - # variables will be empty if the configuration file isn't inside - # a motif-specific directory structure. - MOTIF=$(tcar_getPathComponent ${CONFIGURATION} --motif) - MOTIF_NAME=$(tcar_getPathComponent ${CONFIGURATION} --motif-name) - MOTIF_VERSION=$(tcar_getPathComponent ${CONFIGURATION} --motif-version) - - # Use arrays to store section names. This make possible to make - # use of post-rendition and last-rendition concepts. Otherwise it - # would be difficult to predict information about sections inside - # deeper environments. - for SECTION in $(tcar_getConfigSectionNames "${CONFIGURATION}" \ - | egrep ${TCAR_FLAG_FILTER});do - SECTIONS[((++${#SECTIONS[*]}))]="${SECTION}" - done - - local COUNTER=0 - - while [[ ${COUNTER} -lt ${#SECTIONS[*]} ]];do - - # Initialize array variables locally. - local -a TRANSLATIONS - local -a SOURCES - - local SECTION=${SECTIONS[${COUNTER}]} - - local RENDER_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-from") - for SOURCE in ${RENDER_FROM};do - if [[ ${SOURCE} =~ "^/" ]];then - SOURCES[((++${#SOURCES[*]}))]=${SOURCE} - else - SOURCES[((++${#SOURCES[*]}))]=$(dirname ${CONFIGURATION})/${SOURCE} - fi - done - - local RENDER_TYPE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-type") - if [[ -z ${RENDER_TYPE} ]];then - RENDER_TYPE=$(echo ${SOURCES[0]} | sed -r 's/.+\.([[:alpha:]]+)$/\1/') - fi - - local LOCALE_FROM=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "locale-from") - for TRANSLATION in ${LOCALE_FROM};do - if [[ ${TRANSLATION} =~ "^/" ]];then - TRANSLATIONS[((++${#TRANSLATIONS[*]}))]=${TRANSLATION} - else - TRANSLATIONS[((++${#TRANSLATIONS[*]}))]=$(dirname ${CONFIGURATION})/${TRANSLATION} - fi - done - - RENDER_FLOW=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-flow") - if [[ -z ${RENDER_FLOW} ]];then - RENDER_FLOW='article' - fi - - PO_FILE=${TRANSLATIONS[0]} - - # Initialize locale's modules. - for LOCALE_ACTION in ${LOCALE_ACTIONS};do - tcar_setModuleEnvironment "${LOCALE_ACTION}" "${@}" - done - - # Increment section's counter. - COUNTER=$(( ${COUNTER} + 1 )) - - # Reset array variable to avoid undesired concatenations - # between sections blocks. - unset TRANSLATIONS - unset SOURCES - - done - - # Reset array variables and their counters to avoid undesired - # concatenations between configuration files. - unset COUNTER - unset SECTIONS - -}