From 9e894c625bfe01c66cda18ab35241783872e01b2 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 06 2013 00:54:21 +0000 Subject: Update directory structure of locale module. --- diff --git a/Automation/Modules/Locale/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Locale/Modules/Asciidoc/asciidoc.sh deleted file mode 100755 index 5b4a1d3..0000000 --- a/Automation/Modules/Locale/Modules/Asciidoc/asciidoc.sh +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageXmlDocbook.sh -- This function retrieves -# translation messages from Docbook files and creates related portable -# object template for them. -# -# 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function asciidoc { - - # Define location where translation files will be stored in. - local L10N_WORKDIR=$(cli_getLocalizationDir ${ACTIONVAL}) - - # Define regular expression to match extensions of shell scripts - # we use inside the repository. - local EXTENSION='docbook' - - # Define absolute paths to Docbook main file. - local TEMPLATE=$(cli_getFilesList ${ACTIONVAL} \ - --maxdepth=1 --mindepth=1 --type='f' \ - --pattern=".+/$(cli_getRepoName ${ACTIONVAL} -f)\.${EXTENSION}$") - - # Process Docbook template files based on whether it is empty or - # not. When it is empty, it is because there is not a Docbook main - # file in the location provided to centos-art.sh script - # command-line. In this case, we try to create one POT file to all - # docbook files inside the location provided but without expanding - # entities. When Docbook template file is not empty, expand - # entities and create the POT file from a Docbook main file - # instance, with all entities expanded. - if [[ -z ${TEMPLATE} ]];then - locale_updateMessageXmlDocbookNoEntities - else - locale_updateMessageXmlDocbookWithEntities - fi - -} diff --git a/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh b/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh deleted file mode 100755 index 67d6f75..0000000 --- a/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageXmlDocbookNoEntities.sh -- This function creates -# an instance of one or more Docbook files without expanding entities -# inside it, retrieves all translatable strings from main file -# instance, and creates the related portable object template POT for -# them. This is useful to localize Docbook files that aren't direct -# part of a documentation manual but included at rendition time (e.g., -# Docbook files holding license information). -# -# 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessageXmlDocbookNoEntities { - - # In case no path to Docbook main file is not found, go deeper - # into the documentation models directory structure looking for - # files that do match the name of the directory who hold it, and - # use that file as template to initiate localization process. The - # way to reach these files have to be through --filter options - # because we want to respect the restrictions imposed by - # locale_isLocalizable function inside the repository. - # CAUTION: entity expansion the files found this way will be # ignored. - local TEMPLATES=$(cli_getFilesList ${ACTIONVAL} --type='f' \ - --pattern=".+/${FLAG_FILTER}.+\.${EXTENSION}$") - - # Verify number of template files found and define what kind of - # processing they are going to have. In case more than one - # template file be found and because entity expansion will be - # ignored in such case, the whole process of creating the PO file - # for all these templates is also different (simpler) from that we - # use with entity expansion. - - for TEMPLATE in ${TEMPLATES};do - - # Redefine path related to localization work directory. - local L10N_WORKDIR=$(cli_getLocalizationDir "$TEMPLATE") - - # Define location of the file used to create both portable - # object templates (.pot) and portable objects (.po) files. - local MESSAGES="${L10N_WORKDIR}/messages" - - # Print action message. - cli_printMessage "${MESSAGES}.pot" --as-updating-line - - # Extract translatable strings from docbook files and merge - # them down into related messages file. - xml2po -a -l ${CLI_LANG_LL} -o ${MESSAGES}.pot ${TEMPLATE} - - # Verify, initialize or merge portable objects from portable - # object templates. - locale_updateMessagePObjects "${MESSAGES}" - - done - -} diff --git a/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh b/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh deleted file mode 100755 index 352e5b9..0000000 --- a/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageXmlDocbookWithEntities.sh -- This function -# creates an instance of Docbook main file, expands entities inside -# it, retrieves all translatable strings from main file instance, and -# creates the related portable object template POT for them. -# -# 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function locale_updateMessageXmlDocbookWithEntities { - - # Define location of the file used to create both portable object - # templates (.pot) and portable objects (.po) files. - local MESSAGES="${L10N_WORKDIR}/messages" - - # Print action message. - cli_printMessage "${MESSAGES}.pot" --as-updating-line - - # Define file name used as template instance. Here is where we - # expand translation markers and entities before retrieving - # translation messages. - local INSTANCE=$(cli_getTemporalFile "$(basename ${TEMPLATE})") - - # Create the non-translated instance of design model. - cp ${TEMPLATE} ${INSTANCE} - - # Expand common contents inside instance. - cli_exportFunctions "Render/Docbook/docbook_setExpansionLicenses" - docbook_setExpansionLicenses ${INSTANCE} - - # When translated instances are rendered, system entities (e.g., - # `%entity-name;') don't appear in the translated instance (it - # seems that xml2po removes them) and this provokes DocBook - # validation to fail. So in order to pass the validation - # successfully and automate the whole creation of system entities, - # don't let this duty ion users'. Instead, make centos-art.sh - # script responsible of it. - cli_exportFunctions "Render/Docbook/docbook_setExpansionSystemEntities" - docbook_setExpansionSystemEntities ${INSTANCE} - - # Create portable object template from instance. Validate - # translated instance before processing it. This step is very - # important in order to detect document's malformations and warn - # you about it, so you can correct them. - xmllint --valid --noent ${INSTANCE} | xml2po -a -l ${CLI_LANG_LC} - \ - | msgcat --output=${MESSAGES}.pot \ - --width=70 --no-location - - - # Expand translation markers inside file. - cli_expandTMarkers ${INSTANCE} - - # Verify, initialize or merge portable objects from portable - # object templates. - locale_updateMessagePObjects "${MESSAGES}" - -} diff --git a/Automation/Modules/Locale/Modules/Delete/delete.sh b/Automation/Modules/Locale/Modules/Delete/delete.sh new file mode 100755 index 0000000..b6a44f3 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Delete/delete.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +function delete { + + local TRANSLATION='' + + for TRANSLATION in ${TRANSLATIONS[*]};do + tcar_printMessage "${TRANSLATION}" --as-deleting-line + /bin/rm ${TRANSLATION} + done + + +} diff --git a/Automation/Modules/Locale/Modules/Edit/edit.sh b/Automation/Modules/Locale/Modules/Edit/edit.sh new file mode 100755 index 0000000..06913a7 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Edit/edit.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +function edit { + + local TRANSLATION='' + + for TRANSLATION in ${TRANSLATIONS[*]};do + tcar_printMessage "${TRANSLATION}" --as-editing-line + ${TCAR_USER_EDITOR} ${TRANSLATION} + done + +} diff --git a/Automation/Modules/Locale/Modules/Svg/Modules/Delete/delete.sh b/Automation/Modules/Locale/Modules/Svg/Modules/Delete/delete.sh deleted file mode 100755 index 18aed7f..0000000 --- a/Automation/Modules/Locale/Modules/Svg/Modules/Delete/delete.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -function delete { - - locale_deletePoFiles "${TRANSLATIONS[*]}" - -} diff --git a/Automation/Modules/Locale/Modules/Svg/Modules/Edit/edit.sh b/Automation/Modules/Locale/Modules/Svg/Modules/Edit/edit.sh deleted file mode 100755 index 4d8108c..0000000 --- a/Automation/Modules/Locale/Modules/Svg/Modules/Edit/edit.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -function edit { - - locale_editPoFiles "${TRANSLATIONS[*]}" - -} diff --git a/Automation/Modules/Locale/Modules/Svg/Modules/Update/update.sh b/Automation/Modules/Locale/Modules/Svg/Modules/Update/update.sh deleted file mode 100755 index a0abe94..0000000 --- a/Automation/Modules/Locale/Modules/Svg/Modules/Update/update.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -function update { - - local FILE='' - local POT=$(dirname ${CONFIGURATION})/messages.pot - local TEMPFILES='' - - # Define regular expression to match extensions of shell scripts - # we use inside the repository. - local EXTENSION='(svgz|svg)' - - # Process list of directories, one by one. - for FILE in ${SOURCES[*]};do - - local TEMPFILE=$(tcar_getTemporalFile $(basename ${FILE})) - - if [[ $(file -b -i ${FILE}) =~ '^application/x-gzip$' ]];then - /bin/zcat ${FILE} > ${TEMPFILE} - else - /bin/cat ${FILE} > ${TEMPFILE} - fi - - TEMPFILES="${TEMPFILE} ${TEMPFILES}" - - done - - # - if [[ ! -d $(dirname ${TRANSLATIONS[0]}) ]];then - mkdir -p $(dirname ${TRANSLATIONS[0]}) - fi - - # Print action message. - tcar_printMessage "${POT}" --as-creating-line - - # Create the portable object template. - cat ${TEMPFILES} | xml2po -a -l ${TCAR_SCRIPT_LANG_LC} - \ - | msgcat --output=${POT} --width=70 --no-location - - - # Verify, initialize or merge portable objects from portable - # object templates. - locale_updateMessagePObjects "${POT}" - -} diff --git a/Automation/Modules/Locale/Modules/Svg/svg.conf.sh b/Automation/Modules/Locale/Modules/Svg/svg.conf.sh deleted file mode 100755 index bd6d681..0000000 --- a/Automation/Modules/Locale/Modules/Svg/svg.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/Svg/svg.sh b/Automation/Modules/Locale/Modules/Svg/svg.sh deleted file mode 100755 index 8a96ef2..0000000 --- a/Automation/Modules/Locale/Modules/Svg/svg.sh +++ /dev/null @@ -1,35 +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 { - - for LOCALE_ACTION in ${LOCALE_ACTIONS};do - tcar_setModuleEnvironment ${LOCALE_ACTION} "${@}" - done - -} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh new file mode 100755 index 0000000..5b4a1d3 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# +# locale_updateMessageXmlDocbook.sh -- This function retrieves +# translation messages from Docbook files and creates related portable +# object template for them. +# +# 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function asciidoc { + + # Define location where translation files will be stored in. + local L10N_WORKDIR=$(cli_getLocalizationDir ${ACTIONVAL}) + + # Define regular expression to match extensions of shell scripts + # we use inside the repository. + local EXTENSION='docbook' + + # Define absolute paths to Docbook main file. + local TEMPLATE=$(cli_getFilesList ${ACTIONVAL} \ + --maxdepth=1 --mindepth=1 --type='f' \ + --pattern=".+/$(cli_getRepoName ${ACTIONVAL} -f)\.${EXTENSION}$") + + # Process Docbook template files based on whether it is empty or + # not. When it is empty, it is because there is not a Docbook main + # file in the location provided to centos-art.sh script + # command-line. In this case, we try to create one POT file to all + # docbook files inside the location provided but without expanding + # entities. When Docbook template file is not empty, expand + # entities and create the POT file from a Docbook main file + # instance, with all entities expanded. + if [[ -z ${TEMPLATE} ]];then + locale_updateMessageXmlDocbookNoEntities + else + locale_updateMessageXmlDocbookWithEntities + fi + +} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh new file mode 100755 index 0000000..67d6f75 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh @@ -0,0 +1,73 @@ +#!/bin/bash +# +# locale_updateMessageXmlDocbookNoEntities.sh -- This function creates +# an instance of one or more Docbook files without expanding entities +# inside it, retrieves all translatable strings from main file +# instance, and creates the related portable object template POT for +# them. This is useful to localize Docbook files that aren't direct +# part of a documentation manual but included at rendition time (e.g., +# Docbook files holding license information). +# +# 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_updateMessageXmlDocbookNoEntities { + + # In case no path to Docbook main file is not found, go deeper + # into the documentation models directory structure looking for + # files that do match the name of the directory who hold it, and + # use that file as template to initiate localization process. The + # way to reach these files have to be through --filter options + # because we want to respect the restrictions imposed by + # locale_isLocalizable function inside the repository. + # CAUTION: entity expansion the files found this way will be # ignored. + local TEMPLATES=$(cli_getFilesList ${ACTIONVAL} --type='f' \ + --pattern=".+/${FLAG_FILTER}.+\.${EXTENSION}$") + + # Verify number of template files found and define what kind of + # processing they are going to have. In case more than one + # template file be found and because entity expansion will be + # ignored in such case, the whole process of creating the PO file + # for all these templates is also different (simpler) from that we + # use with entity expansion. + + for TEMPLATE in ${TEMPLATES};do + + # Redefine path related to localization work directory. + local L10N_WORKDIR=$(cli_getLocalizationDir "$TEMPLATE") + + # Define location of the file used to create both portable + # object templates (.pot) and portable objects (.po) files. + local MESSAGES="${L10N_WORKDIR}/messages" + + # Print action message. + cli_printMessage "${MESSAGES}.pot" --as-updating-line + + # Extract translatable strings from docbook files and merge + # them down into related messages file. + xml2po -a -l ${CLI_LANG_LL} -o ${MESSAGES}.pot ${TEMPLATE} + + # Verify, initialize or merge portable objects from portable + # object templates. + locale_updateMessagePObjects "${MESSAGES}" + + done + +} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh new file mode 100755 index 0000000..352e5b9 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Update/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh @@ -0,0 +1,74 @@ +#!/bin/bash +# +# locale_updateMessageXmlDocbookWithEntities.sh -- This function +# creates an instance of Docbook main file, expands entities inside +# it, retrieves all translatable strings from main file instance, and +# creates the related portable object template POT for them. +# +# 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function locale_updateMessageXmlDocbookWithEntities { + + # Define location of the file used to create both portable object + # templates (.pot) and portable objects (.po) files. + local MESSAGES="${L10N_WORKDIR}/messages" + + # Print action message. + cli_printMessage "${MESSAGES}.pot" --as-updating-line + + # Define file name used as template instance. Here is where we + # expand translation markers and entities before retrieving + # translation messages. + local INSTANCE=$(cli_getTemporalFile "$(basename ${TEMPLATE})") + + # Create the non-translated instance of design model. + cp ${TEMPLATE} ${INSTANCE} + + # Expand common contents inside instance. + cli_exportFunctions "Render/Docbook/docbook_setExpansionLicenses" + docbook_setExpansionLicenses ${INSTANCE} + + # When translated instances are rendered, system entities (e.g., + # `%entity-name;') don't appear in the translated instance (it + # seems that xml2po removes them) and this provokes DocBook + # validation to fail. So in order to pass the validation + # successfully and automate the whole creation of system entities, + # don't let this duty ion users'. Instead, make centos-art.sh + # script responsible of it. + cli_exportFunctions "Render/Docbook/docbook_setExpansionSystemEntities" + docbook_setExpansionSystemEntities ${INSTANCE} + + # Create portable object template from instance. Validate + # translated instance before processing it. This step is very + # important in order to detect document's malformations and warn + # you about it, so you can correct them. + xmllint --valid --noent ${INSTANCE} | xml2po -a -l ${CLI_LANG_LC} - \ + | msgcat --output=${MESSAGES}.pot \ + --width=70 --no-location - + + # Expand translation markers inside file. + cli_expandTMarkers ${INSTANCE} + + # Verify, initialize or merge portable objects from portable + # object templates. + locale_updateMessagePObjects "${MESSAGES}" + +} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Svg/Modules/Update/update.sh b/Automation/Modules/Locale/Modules/Update/Modules/Svg/Modules/Update/update.sh new file mode 100755 index 0000000..a0abe94 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Update/Modules/Svg/Modules/Update/update.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +function update { + + local FILE='' + local POT=$(dirname ${CONFIGURATION})/messages.pot + local TEMPFILES='' + + # Define regular expression to match extensions of shell scripts + # we use inside the repository. + local EXTENSION='(svgz|svg)' + + # Process list of directories, one by one. + for FILE in ${SOURCES[*]};do + + local TEMPFILE=$(tcar_getTemporalFile $(basename ${FILE})) + + if [[ $(file -b -i ${FILE}) =~ '^application/x-gzip$' ]];then + /bin/zcat ${FILE} > ${TEMPFILE} + else + /bin/cat ${FILE} > ${TEMPFILE} + fi + + TEMPFILES="${TEMPFILE} ${TEMPFILES}" + + done + + # + if [[ ! -d $(dirname ${TRANSLATIONS[0]}) ]];then + mkdir -p $(dirname ${TRANSLATIONS[0]}) + fi + + # Print action message. + tcar_printMessage "${POT}" --as-creating-line + + # Create the portable object template. + cat ${TEMPFILES} | xml2po -a -l ${TCAR_SCRIPT_LANG_LC} - \ + | msgcat --output=${POT} --width=70 --no-location - + + # Verify, initialize or merge portable objects from portable + # object templates. + locale_updateMessagePObjects "${POT}" + +} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.conf.sh b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.conf.sh new file mode 100755 index 0000000..bd6d681 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.conf.sh @@ -0,0 +1,2 @@ +#!/bin/bash +declare -x TCAR_SCRIPT_MODULES_BASEDIR=${MODULE_DIR_MODULES} diff --git a/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh new file mode 100755 index 0000000..494d3da --- /dev/null +++ b/Automation/Modules/Locale/Modules/Update/Modules/Svg/svg.sh @@ -0,0 +1,70 @@ +#!/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 FILE='' + local POT=$(dirname ${CONFIGURATION})/messages.pot + local TEMPFILES='' + + # Define regular expression to match extensions of shell scripts + # we use inside the repository. + local EXTENSION='(svgz|svg)' + + # Process list of directories, one by one. + for FILE in ${SOURCES[*]};do + + local TEMPFILE=$(tcar_getTemporalFile $(basename ${FILE})) + + if [[ $(file -b -i ${FILE}) =~ '^application/x-gzip$' ]];then + /bin/zcat ${FILE} > ${TEMPFILE} + else + /bin/cat ${FILE} > ${TEMPFILE} + fi + + TEMPFILES="${TEMPFILE} ${TEMPFILES}" + + done + + # + if [[ ! -d $(dirname ${TRANSLATIONS[0]}) ]];then + mkdir -p $(dirname ${TRANSLATIONS[0]}) + fi + + # Print action message. + tcar_printMessage "${POT}" --as-creating-line + + # Create the portable object template. + cat ${TEMPFILES} | xml2po -a -l ${TCAR_SCRIPT_LANG_LC} - \ + | msgcat --output=${POT} --width=70 --no-location - + + # Verify, initialize or merge portable objects from portable + # object templates. + locale_updateMessagePObjects "${POT}" + +} diff --git a/Automation/Modules/Locale/locale_deletePoFiles.sh b/Automation/Modules/Locale/locale_deletePoFiles.sh deleted file mode 100755 index f59990e..0000000 --- a/Automation/Modules/Locale/locale_deletePoFiles.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -function locale_deletePoFiles { - - local TRANSLATIONS="${1}" - local TRANSLATION='' - - for TRANSLATION in ${TRANSLATIONS};do - tcar_printMessage "${TRANSLATION}" --as-deleting-line - /bin/rm ${TRANSLATION} - done - -} diff --git a/Automation/Modules/Locale/locale_editPoFiles.sh b/Automation/Modules/Locale/locale_editPoFiles.sh deleted file mode 100755 index 6a266d3..0000000 --- a/Automation/Modules/Locale/locale_editPoFiles.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -function locale_editPoFiles { - - local TRANSLATIONS="${1}" - local TRANSLATION='' - - for TRANSLATION in ${TRANSLATIONS};do - tcar_printMessage "${TRANSLATION}" --as-editing-line - ${TCAR_USER_EDITOR} ${TRANSLATION} - done - - -} diff --git a/Automation/Modules/Locale/locale_getOptions.sh b/Automation/Modules/Locale/locale_getOptions.sh index b4e9cc4..5da74fb 100755 --- a/Automation/Modules/Locale/locale_getOptions.sh +++ b/Automation/Modules/Locale/locale_getOptions.sh @@ -84,6 +84,10 @@ function locale_getOptions { esac done + if [[ -z ${LOCALE_ACTIONS} ]];then + LOCALE_ACTIONS='update' + fi + # Redefine arguments using current positional parameters. Only # paths should remain as arguments, at this point. TCAR_ARGUMENTS="${@}" diff --git a/Automation/Modules/Locale/locale_updateMessages.sh b/Automation/Modules/Locale/locale_updateMessages.sh deleted file mode 100755 index d397dcf..0000000 --- a/Automation/Modules/Locale/locale_updateMessages.sh +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/bash -# -# locale_updateMessages.sh -- This function extracts translatable -# strings from both XML-based files (using xml2po) and shell scripts -# (using xgettext). Translatable strings are initially stored in -# portable objects templates (.pot) which are later merged into -# portable objects (.po) in order to be optionally converted as -# machine objects (.mo). -# -# 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 locale_updateMessages { - - case ${RENDER_TYPE} in - - 'svg' ) - locale_convertSvgToPo - ;; - - 'asciidoc' ) - locale_convertAsciidocToPo - ;; - - 'sh' ) - locale_convertShellToPo - ;; - - * ) - cli_printMessage "`gettext "Couldn't find a valid render-type."`" --as-error-line - ;; - - esac - -}