From 52ee2e5b18bce8baad1d7aa9c880f9d87247fcd7 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 06 2013 00:54:21 +0000 Subject: Update automation scripts directory structure. --- diff --git a/Automation/Manuals/centos-art.sh-render.asciidoc b/Automation/Manuals/centos-art.sh-render.asciidoc index 32e7763..cf9e406 100644 --- a/Automation/Manuals/centos-art.sh-render.asciidoc +++ b/Automation/Manuals/centos-art.sh-render.asciidoc @@ -10,15 +10,15 @@ configuration files. Synopsis -------- -+centos-art.sh render [OPTIONS] [DIRECTORY ...]+ +centos-art.sh render [OPTIONS] [DIRECTORY ...] Description ----------- When you execute the *render* module, it looks for configuration files -inside the +DIRECTORY+ specified in the command-line and processes -them in the order they were found. When no +DIRECTORY+ is specified to -*centos-art.sh* script, the *render* module looks for configuration +inside the ``DIRECTORY'' specified in the command-line and processes +them in the order they were found. When no ``DIRECTORY'' is specified +to *centos-art.sh* script, the *render* module looks for configuration files inside the current directory it was executed from. If no configuration file is found, the *render* module will end its execution with an error message. @@ -35,9 +35,9 @@ The *render* module accepts the following options: *--filter="REGEX"*:: This option reduces the number of section blocks inside configuration files the *render* module will take for processing. - +REGEX+ is a regular expression pattern matching one or more + ``REGEX'' is a regular expression pattern matching one or more section names inside the configuration files found under - +DIRECTORY+. + ``DIRECTORY''. Configuration Files ------------------- @@ -61,68 +61,46 @@ introduced by using the +#+ character at the beginning of lines. Commentaries defined this way are excluded from processing so you can use them freely. -The configuration files are processed from top to bottom. This is very -important aspect to consider in situations where you need to grantee -an specific content production priority inside a configuration file -(e.g., you have several files in a configuration file and need to -produce some of them before others). So, section blocks set first in -the configuration file are processed first and section blocks set -later are processed later. +The configuration files are processed from top to bottom. This is a +very important aspect to consider in situations where you need to +grantee specific priority for content production (e.g., you have +several files in a configuration file and need to produce some of them +before others). So, because configuration files are processed from top +to bottom, section blocks set first in the configuration file are +processed first and section blocks set later are processed later. The configuration files can be divided in separated configuration -files to produce section blocks with an specific priority. For -example, if you have the file +render.conf+, you can divide its -content in +render-1.conf+, +render-2.conf+ to produce section blocks -inside +render-1.conf+ first and +render-2.conf+ later. This sort of -division is very useful when the configuration file begins to grow, or -you want to control the order in which specific groups of files are -produced inside +DIRECTORY+. - -To describe final files production, the *render* module's accepts the -following configuration variables inside configuration files: +files to produce specific section blocks with a given priority. For +example, if you have the file ``render.conf'', you can divide its +content in ``render-1.conf'', ``render-2.conf'' to produce section +blocks inside ``render-1.conf'' first and ``render-2.conf'' later. +This sort of division might be very useful when the configuration file +begins to grow, or you want to control the order in which specific +groups of files are produced inside ``DIRECTORY''. + +Inside configuration files, configuration variables can take different +meanings based on the section contexts. The context of a section block +is defined by the *render-type* variables. *render-type*:: - Optional. This variable specifies the sort of content rendition + Optional. This variable specifies the type of content rendition the *render* module will perform. This variable can take one of - the following values: +archive+, +asciidoc+, +compress+, +direct+, - +palette+, and +svg+. When this variable is not present in the - configuration file or has not a value set, the *render* module - tries to determine the sort of rendition to perform based on the - first file path passed through *render-from* variable. + the following values: ``archive'', ``asciidoc'', ``compress'', + ``images'', ``palette'', and ``svg''. When this variable is not + set, the *render* module tries to determine the type of rendition + based on the file extension of the first file passed through + *render-from* variable. If no valid value is found there either, + the *render* module ends with an error message. *render-from*:: Required. This variable specifies the file name of the source file (design model) used to produce the final file specified in the section line. This option can receive absolute paths and relative - paths. Absolute paths begin with a slash (+/+) character while - relative paths begin with the dot slash (+./+) characters or no - character at all. -*locale-from*:: - Optional. This variable specifies the absolute path to the - +messages.po+ file used as reference to produce localized versions - of the final files. -+ -When this variable is provided, the files you specified in the -*render-from* variable must be XML-based files (e.g., SVG, DocBook). -The localization of source files will take place when the current -locale information of your terminal session is different to English -(e.g., +LANG=es_ES.UTF-8+). -+ -Localized versions of the final file will be stored in a -locale-specific directory placed at the same level of the related -configuration file. -+ -This variable accepts more than one value. If you pass more than one -translation file through *locale-from* variable, the first file in the -list will always contain the source file translatable strings and the -rest will be considered as shared translations files. Example of -shared translation files include files containing licenses -translations. Shared translation files won't be initiated or updated -by *render* module. -+ -To initiate new +messages.po+ files or update existent ones, you need -to use the *locale* module of *centos-art.sh* script. + paths. Absolute paths begin with a slash (``/'') character while + relative paths begin with the dot slash (``./'') characters or no + character at all. This variable can receive more than one value by + using either path expansion in one variable definition, or several + variables definitions. -[[using-paths]] Using Paths ~~~~~~~~~~~ @@ -155,13 +133,12 @@ spaces (e.g., +/some/dir/{file1,file2,file3}+). In order for path expansion to work correctly, all the file names you put inside the curly brackets' list must exist in the location specified first. -[[using-environment-variables]] Using Environment Variables ~~~~~~~~~~~~~~~~~~~~~~~~~~~ The configuration files let you to use environment variables inside -them. This might be very useful in situation where you need to provide -absolute paths based on specific information (e.g., the current locale +them. This might result very useful when you need to provide absolute +paths based on variable information (e.g., the current locale information). Some of the most important environment variables used by *centos-art.sh* script -and its configuration files- are described below: @@ -170,7 +147,7 @@ below: This variable contains the absolute path to your repository's working copy. The value of this variable is defined as read-only inside *centos-art.sh* script and cannot be modified later. As a - matter of convenience, users make use of their +~/.bash_profile+ + matter of convenience, users make use of their ``~/.bash_profile'' file to define this variable there and, this way, skip the sometimes annoyance absolute path questioning the *centos-art.sh* script does in order to know the absolute path of the working copy @@ -180,58 +157,21 @@ Whenever you set absolute paths inside configuration files to refer locations inside your working copy, it is necessary that you use the +TCAR_BASEDIR+ environment variable in front of each path definition you set. - -+LANG+:: - This variable contains the environment's current locale - information. - +TCAR_SCRIPT_LANG_LL+:: This variable contains the language part of the current locale information. For instance, if the current locale is ``en_US.UTF-8'', the value of this variable would be ``en''. - +TCAR_SCRIPT_LANG_CC+:: This variable contains the country part of the current locale information. For instance, if the current locale is ``en_US.UTF-8'', the value of this variable would be ``US''. - +TCAR_SCRIPT_LANG_LC+:: This variable contains the current locale information in ll_CC format (e.g., es_ES). ++LANG+:: + This variable contains the environment's current locale + information. -+HOME+:: - This variable contains the absolute path to current user's home - directory. The value of this variable is set by the operating - system when the user opens a terminal session. -+ -Whenever you need to set user-specific absolute paths inside -configuration files, use this variable. - -[[rendering-files-directly]] -Rendering Image Files From Other Image Files -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -To render image files from other image files, the *render-type* -variable must be set to ``images'' and one or more image files must be -provided in the *render-from* variable. When the *render* module finds -a section block with this characteristics, it applies the value of -*command* variable to all files found in *render-from* variable to -produce the final file specified in the section name. - -When the *command* variable is not specified, the ``/usr/bin/convert --append'' command is used as default. This command takes all the -images passed through *render-from* and appends them from top to -bottom and saves the result in the file you specified in the section -name. When you render files this way, the order in which you define -source files through *render-from* may affect the final result based -in the *command* you provided. - -The ``images'' rendition type provides an interface for external image -manipulation programs, like ImageMagick and NetPbm. You can use these -programs to manipulate images in great detail through the -command-line. - -[[rendering-archives]] Rendering Archives ~~~~~~~~~~~~~~~~~~ @@ -242,7 +182,6 @@ final file specified in the section line. When the command variable is not specified, the +/bin/tar --remove-files -czf+ command is used as default. -[[rendering-image-files]] Rendering Image Files ~~~~~~~~~~~~~~~~~~~~~ @@ -339,7 +278,29 @@ tool set, run the following command: *+identify -list format+*. available. In case they don't exist the *render* module ends its execution with an error message. -[[rendering-images-with-reduced-number-of-colros]] +Rendering Image Files From Other Image Files +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To render image files from other image files, the *render-type* +variable must be set to ``images'' and one or more image files must be +provided in the *render-from* variable. When the *render* module finds +a section block with this characteristics, it applies the value of +*command* variable to all files found in *render-from* variable to +produce the final file specified in the section name. + +When the *command* variable is not specified, the ``/usr/bin/convert +-append'' command is used as default. This command takes all the +images passed through *render-from* and appends them from top to +bottom and saves the result in the file you specified in the section +name. When you render files this way, the order in which you define +source files through *render-from* may affect the final result based +in the *command* you provided. + +The ``images'' rendition type provides an interface for external image +manipulation programs, like ImageMagick and NetPbm. You can use these +programs to manipulate images in great detail through the +command-line. + Rendering Images With Reduced Number Of Colors ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -468,19 +429,30 @@ them. When the *formats* variable is not set, the ``xhtml'' value is used as default value. -Localization Files ------------------- - -When the current locale code you are using in your terminal's session -is not English, the *render* module uses localization files specified -by *locale-from* variable to produce final versions of source files -for your current locale information. Localization files are created -and edited through *locale* module. Thus, in order for you to produce -localized content you need to create the localization files through -*locale* module first and then run the *render* module. - -To know more about localization files, see *locale* module's -documentation. +Rendering Localized Images +-------------------------- + +To produce localized content, you need to set the *locale-from* +variable in the section block you want to provide translations and +point its value to the translation file where string translations will +take place. Then, you need to check the value of LANG environment +variable to be sure it has the locale information you want to +translate messages for. + +If the LANG environment variable has the value you expect, run the +*locale* module on the ``DIRECTORY'' you want to locale content. This +read the source files you specified in *render-from* variable and +would create the translation files (a.k.a., portable objects) you need +to edit to provide the string translations from one language to +another. Verify the translation file exist and edit it to provide the +strings translations. Once the strings have been translated, execute +the *render* module on the ``DIRECTORY''. + +When the *render* module finds the *locale-from* variable in a section +block, it uses the *xml2po* program to create a localized instance of +each source file it finds in *render-from* variable. Then, using the +source files' localized instances, it produces the final files based +on *render-type* variable's value. Examples -------- diff --git a/Automation/Manuals/render.conf b/Automation/Manuals/render.conf index e262a7c..c0b6156 100644 --- a/Automation/Manuals/render.conf +++ b/Automation/Manuals/render.conf @@ -5,3 +5,11 @@ render-from = "centos-art.sh-render.asciidoc" locale-from = "${TCAR_SCRIPT_LANG_LC}/$(basename ${TARGET}).po" formats = "xhtml manpage" mansect = "1" + +[centos-art.sh-locale] +render-type = "asciidoc" +render-flow = "manpage" +render-from = "centos-art.sh-locale.asciidoc" +locale-from = "${TCAR_SCRIPT_LANG_LC}/$(basename ${TARGET}).po" +formats = "xhtml manpage" +mansect = "1" diff --git a/Automation/Modules/Locale/Modules/Asciidoc/asciidoc.sh b/Automation/Modules/Locale/Modules/Asciidoc/asciidoc.sh new file mode 100755 index 0000000..5b4a1d3 --- /dev/null +++ b/Automation/Modules/Locale/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/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh b/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookNoEntities.sh new file mode 100755 index 0000000..67d6f75 --- /dev/null +++ b/Automation/Modules/Locale/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/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh b/Automation/Modules/Locale/Modules/Asciidoc/asciidoc_updateMessageXmlDocbookWithEntities.sh new file mode 100755 index 0000000..352e5b9 --- /dev/null +++ b/Automation/Modules/Locale/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/Svg/Modules/Delete/delete.sh b/Automation/Modules/Locale/Modules/Svg/Modules/Delete/delete.sh new file mode 100755 index 0000000..18aed7f --- /dev/null +++ b/Automation/Modules/Locale/Modules/Svg/Modules/Delete/delete.sh @@ -0,0 +1,7 @@ +#!/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 new file mode 100755 index 0000000..4d8108c --- /dev/null +++ b/Automation/Modules/Locale/Modules/Svg/Modules/Edit/edit.sh @@ -0,0 +1,7 @@ +#!/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 new file mode 100755 index 0000000..a0abe94 --- /dev/null +++ b/Automation/Modules/Locale/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/Svg/svg.conf.sh b/Automation/Modules/Locale/Modules/Svg/svg.conf.sh new file mode 100755 index 0000000..bd6d681 --- /dev/null +++ b/Automation/Modules/Locale/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/Svg/svg.sh b/Automation/Modules/Locale/Modules/Svg/svg.sh new file mode 100755 index 0000000..8a96ef2 --- /dev/null +++ b/Automation/Modules/Locale/Modules/Svg/svg.sh @@ -0,0 +1,35 @@ +#!/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/Xml/xml_updateMessageXml.sh b/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXml.sh deleted file mode 100755 index cf7bfde..0000000 --- a/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXml.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageXml.sh -- This function parses XML-based files -# (e.g., Scalable Vector Graphics and Docbook files), retrieves -# translatable strings and creates/update gettext portable objects. -# -# 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_updateMessageXml { - - # Define what kind of XML file we are generating translation - # messages for. This is relevant because scalable vector graphics - # (SVG) files are not using entity expansion while DocBook files - # do. - if [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Documentation/Models/Docbook/[[:alnum:]-]+$" ]];then - - locale_updateMessageXmlDocbook - - # Combine template messages and licenses messages so when - # template be merged into the final portable object the - # translations be there. If we cannot treat licenses as - # independent documents (e.g., through XInclude), then lets - # keep translation messages as synchronized as possible. - - elif [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Identity/Models/.+$" ]] \ - || [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Documentation/Models/Svg/.+$" ]];then - - locale_updateMessageXmlSvg - - else - - cli_printMessage "`gettext "The path provided doesn't support localization."`" --as-error-line - - fi - -} diff --git a/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXmlDocbook.sh b/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXmlDocbook.sh deleted file mode 100755 index 04448e2..0000000 --- a/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXmlDocbook.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 locale_updateMessageXmlDocbook { - - # 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/Xml/xml_updateMessageXmlDocbookNoEntities.sh b/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXmlDocbookNoEntities.sh deleted file mode 100755 index 67d6f75..0000000 --- a/Automation/Modules/Locale/Modules/Xml/xml_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/Xml/xml_updateMessageXmlDocbookWithEntities.sh b/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXmlDocbookWithEntities.sh deleted file mode 100755 index 352e5b9..0000000 --- a/Automation/Modules/Locale/Modules/Xml/xml_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/Xml/xml_updateMessageXmlSvg.sh b/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXmlSvg.sh deleted file mode 100755 index d41bec1..0000000 --- a/Automation/Modules/Locale/Modules/Xml/xml_updateMessageXmlSvg.sh +++ /dev/null @@ -1,101 +0,0 @@ -#!/bin/bash -# -# locale_updateMessageXmlSvg.sh -- This function parses XML-based -# files (e.g., scalable vector graphics), retrieves translatable -# strings and creates/update gettext portable objects. -# -# 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_updateMessageXmlSvg { - - # Inside `Identity/Models' and Documentation/Models/Svg/, design - # models can be compressed or uncompressed. Because of this we - # cannot process all the design models in one unique way. Instead, - # we need to treat them individually based on their file type. - - local DIR='' - local DIRS='' - - # Define regular expression to match extensions of shell scripts - # we use inside the repository. - local EXTENSION='(svgz|svg)' - - # Build list of directories in which we want to look files for. - local DIRS=$(cli_getFilesList ${ACTIONVAL} \ - --pattern="${ACTIONVAL}/${FLAG_FILTER}") - - # Process list of directories, one by one. - for DIR in $DIRS;do - - # Reset information related to temporal files. - local TEMPFILE='' - local TEMPFILES='' - - # Redefine localization working directory using the current - # directory. The localization working directory is the place - # where POT and PO files are stored inside the working copy. - local L10N_WORKDIR=$(cli_getLocalizationDir "${DIR}") - - # Prepare working directory to receive translation files. - locale_prepareWorkingDirectory ${L10N_WORKDIR} - - # Redefine final location of messages.po file, based on - # current directory. - MESSAGES=${L10N_WORKDIR}/messages - - # Build list of files we want to work with. - FILES=$(cli_getFilesList ${DIR} --pattern="${DIR}/.+\.${EXTENSION}") - - for FILE in $FILES;do - - # Redefine temporal file based on file been processed. - TEMPFILE=$(cli_getTemporalFile $(basename ${FILE})) - - # Update the command used to read content of XML files. - if [[ $(file -b -i $FILE) =~ '^application/x-gzip$' ]];then - - # Create uncompressed copy of file. - /bin/zcat $FILE > $TEMPFILE - - else - - # Create uncompressed copy of file. - /bin/cat $FILE > $TEMPFILE - - fi - - # Concatenate temporal files into a list so we can process - # them later through xml2po, all at once. - TEMPFILES="${TEMPFILE} ${TEMPFILES}" - - done - - # Create the portable object template. - cat $TEMPFILES | xml2po -a -l ${CLI_LANG_LC} - \ - | msgcat --output=${MESSAGES}.pot --width=70 --no-location - - - # Verify, initialize or merge portable objects from portable - # object templates. - locale_updateMessagePObjects "${MESSAGES}" - - done - -} diff --git a/Automation/Modules/Locale/locale.conf.sh b/Automation/Modules/Locale/locale.conf.sh old mode 100644 new mode 100755 index bd6d681..b7589f3 --- a/Automation/Modules/Locale/locale.conf.sh +++ b/Automation/Modules/Locale/locale.conf.sh @@ -1,2 +1,3 @@ #!/bin/bash +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 58e2375..b896fc4 100755 --- a/Automation/Modules/Locale/locale.sh +++ b/Automation/Modules/Locale/locale.sh @@ -1,14 +1,18 @@ #!/bin/bash +###################################################################### # -# locale.sh -- This function provides internationalization features -# for centos-art.sh script through GNU gettext standard processes. +# locale.sh -- This function provides internationalization features +# for centos-art.sh script through GNU gettext standard processes. +# +# 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. +# 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 @@ -19,81 +23,49 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function locale { - local ACTIONNAMS='' - local ACTIONNAM='' - local ACTIONVAL='' - - # Initialize machine object flag (`--dont-create-mo'). This flag - # controls whether the centos-art.sh script does create/update - # machine object (MO) files from related portable object (PO) - # files or not. By default, MO files are created. - local FLAG_DONT_CREATE_MO='false' - - # Define localization (l10n) base directory. This is the place - # where all translation messages are organized in. Translation - # messages are organized herein using the same layout of the - # components they represent under the `Identity', - # `Documentation/Manuals' or `Scripts' directory structures. The - # localization base directory must be used as source location for - # control version system operations (e.g., status, update, commit, - # etc.). Otherwise, it would be difficult to add directory - # structures that have several levels down from the localization - # base directory up to the repository (e.g., - # subversion-1.4.2-4.el5_3.1.i386.rpm doesn't support recursive - # creation of directories which parent directories doesn't - # exist.). - local L10N_BASEDIR="${TCAR_WORKDIR}/Locales" - - # Verify current locale information to avoid English messages from - # being localized to themselves. The English language is used as - # reference to write translatable strings inside the source files. - if [[ ${CLI_LANG_LC} =~ '^en' ]];then - cli_printMessage "`gettext "The English language cannot be localized to itself."`" --as-error-line - fi - # Interpret arguments and options passed through command-line. - locale_getOptions + locale_getOptions "${@}" # Redefine positional parameters using ARGUMENTS. At this point, # option arguments have been removed from ARGUMENTS variable and # only non-option arguments remain in it. - eval set -- "${ARGUMENTS}" + eval set -- "${TCAR_ARGUMENTS}" - # Loop through non-option arguments passed to centos-art.sh script - # through its command-line. - for ACTIONVAL in "$@";do + # Verify current locale information to avoid English messages from + # being localized to themselves. The English language is used as + # reference to write translatable strings inside the source files. + if [[ ${TCAR_SCRIPT_LANG_LC} =~ '^en' ]];then + tcar_printMessage "`gettext "The English language cannot be localized to itself."`" --as-error-line + fi - # Don't call locale_isLocalizable function here. Remember that - # this function (i.e., locale) is called from other functions - # using the cli_runFnEnvironment function to determine whether - # a location can accept or not localized messages. If you put - # the locale_isLocalizable function here, you would be - # duplicating its execution. + # Process directories passed as arguments. + for DIRECTORY in "$@";do # 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. - ACTIONVAL=$(cli_checkRepoDirSource ${ACTIONVAL}) + DIRECTORY=$(tcar_checkRepoDirSource ${DIRECTORY}) + + # Retrieve list of configuration files from directory. + CONFIGURATIONS=$(tcar_getFilesList ${DIRECTORY} \ + --pattern=".+/.+\.conf$" --type="f") # Verify non-option arguments passed to centos-art.sh - # command-line. It should point to an existent directory under - # version control inside the working copy. Otherwise, if it - # doesn't point to a directory under version control, finish - # the script execution with an error message. - cli_checkFiles ${ACTIONVAL} -d --is-versioned - - # Execute localization actions provided to centos-art.sh - # script through its command-line. Notice that localization - # actions will be executed in the same order they were - # provided in the command-line. - for ACTIONNAM in ${ACTIONNAMS};do - ${ACTIONNAM} + # 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 ${CONFIGURATIONS} -f + + # Process each configuration file. + for CONFIGURATION in ${CONFIGURATIONS};do + locale_setLocaleType "${@}" done done diff --git a/Automation/Modules/Locale/locale_combineLicenseMessages.sh b/Automation/Modules/Locale/locale_combineLicenseMessages.sh deleted file mode 100755 index 2e9868d..0000000 --- a/Automation/Modules/Locale/locale_combineLicenseMessages.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# locale_combineLicenseMessages.sh -- This function combines template -# messages with license messages. -# -# 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_combineLicenseMessages { - - if [[ $# -lt 1 ]];then - cli_printMessage "`gettext "One argument is required."`" --as-error-message - fi - - local TRANSLATION_INSTANCE=$1 - local TRANSLATION_TEMPLATE=$2 - - local DOCBOOK_LOCALES=$(echo $DOCBOOK_MODELS \ - | sed -r "s!${TCAR_WORKDIR}/!${TCAR_WORKDIR}/Locales/!") - - # Define list of all files you want to combine. - local FILES="${DOCBOOK_LOCALES}/${CLI_LANG_LC}/messages.po \ - ${DOCBOOK_LOCALES}/${CLI_LANG_LC}/messages.po \ - ${TRANSLATION_TEMPLATE}" - - # Be sure the files we want to combine do exist. - cli_checkFiles -e ${FILES} - - # Combine files. - msgcat --output=${TRANSLATION_INSTANCE} \ - --width=70 --no-location --use-first ${FILES} - -} diff --git a/Automation/Modules/Locale/locale_deleteMessages.sh b/Automation/Modules/Locale/locale_deleteMessages.sh deleted file mode 100755 index 6956257..0000000 --- a/Automation/Modules/Locale/locale_deleteMessages.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# -# locale_deleteMessages.sh -- This function deletes the source files' -# localization directory from the working copy in conjunction with all -# portable objects and machine objects inside it. -# -# 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_deleteMessages { - - # Print separator line. - cli_printMessage '-' --as-separator-line - - # Print action message. - cli_printMessage "$L10N_WORKDIR" --as-deleting-line - - # Verify existence of localization working directory. We cannot - # remove translation files that don't exist. - cli_checkFiles -e "$L10N_WORKDIR" - - # Delete localization working directory using subversion quietly. - ${SVN} del "$L10N_WORKDIR" --quiet - -} diff --git a/Automation/Modules/Locale/locale_deletePoFiles.sh b/Automation/Modules/Locale/locale_deletePoFiles.sh new file mode 100755 index 0000000..f59990e --- /dev/null +++ b/Automation/Modules/Locale/locale_deletePoFiles.sh @@ -0,0 +1,13 @@ +#!/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_editMessages.sh b/Automation/Modules/Locale/locale_editMessages.sh deleted file mode 100755 index 5b942ee..0000000 --- a/Automation/Modules/Locale/locale_editMessages.sh +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/bash -# -# locale_editMessages.sh -- This function edits portable objects (.po) -# using default text editor. -# -# 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_editMessages { - - # Verify directory passed as non-option argument to be sure it - # supports localization. - locale_isLocalizable "${ACTIONVAL}" - - local PO_FILE='' - local PO_FILES='' - - # Define location where translation files will be stored in - # without language information in it. The language information is - # put later, when we build the list of files. - local L10N_WORKDIR=$(cli_getLocalizationDir "${ACTIONVAL}" "--no-lang") - - # Prepare working directory to receive translation files. Don't do - # this here. It is already done as part the update actions, but we - # need it here for those cases when no update action is run and - # one execute the edit option. - locale_prepareWorkingDirectory ${L10N_WORKDIR} - - # Define list of PO files to process based on paths provided as - # non-option arguments through centos-art.sh script command-line. - if [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/(Documentation/Models/(Docbook|Svg)|Identity/Models)/.*$" ]];then - - # Do not create MO files for XML-based files. - FLAG_DONT_CREATE_MO='true' - - fi - - # Define list of PO files we want to work with. Don't forget to - # include the language information here. - PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --type="f" \ - --pattern=".+/${FLAG_FILTER}/${CLI_LANG_LC}/messages\.po$") - - # Verify list of PO files. - if [[ $PO_FILES = "" ]];then - cli_printMessage "`gettext "The path provided hasn't translations yet."`" --as-error-line - else - cli_printMessage '-' --as-separator-line - fi - - # Synchronize changes between repository and working copy. At this - # point, changes in the repository are merged in the working copy - # and changes in the working copy committed up to repository. - cli_synchronizeRepoChanges "${PO_FILES}" - - # Loop through list of PO files to process in order to edit them - # one by one using user's default text editor. - for PO_FILE in ${PO_FILES};do - - # Print the file we are editing. - cli_printMessage "${PO_FILE}" --as-updating-line - - # Use default text editor to edit the PO file. - eval ${EDITOR} ${PO_FILE} - - done - - # 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_updateMessageBinary - - # Synchronize changes between repository and working copy. At this - # point, changes in the repository are merged in the working copy - # and changes in the working copy committed up to repository. - cli_synchronizeRepoChanges "${PO_FILES}" - -} diff --git a/Automation/Modules/Locale/locale_editPoFiles.sh b/Automation/Modules/Locale/locale_editPoFiles.sh new file mode 100755 index 0000000..6a266d3 --- /dev/null +++ b/Automation/Modules/Locale/locale_editPoFiles.sh @@ -0,0 +1,14 @@ +#!/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_getLanguageName.sh b/Automation/Modules/Locale/locale_getLanguageName.sh index 9872fab..a73730d 100755 --- a/Automation/Modules/Locale/locale_getLanguageName.sh +++ b/Automation/Modules/Locale/locale_getLanguageName.sh @@ -27,7 +27,7 @@ function locale_getLanguageName { local LANGNAME="`gettext "Unknown"`" - case ${CLI_LANG_LL} in + case ${TCAR_SCRIPT_LANG_LL} in 'aa' ) LANGNAME="`gettext "Afar"`" diff --git a/Automation/Modules/Locale/locale_getOptions.sh b/Automation/Modules/Locale/locale_getOptions.sh index c844614..b4e9cc4 100755 --- a/Automation/Modules/Locale/locale_getOptions.sh +++ b/Automation/Modules/Locale/locale_getOptions.sh @@ -27,70 +27,44 @@ function locale_getOptions { # Define short options we want to support. - local ARGSS="h,q" + local ARGSS="h" # Define long options we want to support. - local ARGSL="help,quiet,filter:,answer-yes,update,edit,delete,dont-create-mo,is-localizable,synchronize" + local ARGSL="help,filter:,update,edit,delete" - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments + # Redefine arguments using getopt(1) command parser. + tcar_setArguments "${@}" - # Reset positional parameters using output from (getopt) argument - # parser. - eval set -- "${ARGUMENTS}" + # Reset positional parameters on this function, using output + # produced from (getopt) arguments parser. + eval set -- "${TCAR_ARGUMENTS}" # Look for options passed through command-line. while true; do case "$1" in -h | --help ) - cli_runFnEnvironment help --read --format="texinfo" "tcar-fs::scripts:bash-functions-locale" - shift 1 + tcar_printHelp exit ;; - -q | --quiet ) - FLAG_QUIET="true" - shift 1 - ;; - --filter ) - FLAG_FILTER="$2" + TCAR_FLAG_FILTER="$2" shift 2 ;; - --answer-yes ) - FLAG_ANSWER="true" - shift 1 - ;; - --update ) - ACTIONNAMS="$ACTIONNAMS locale_updateMessages" + LOCALE_ACTIONS="$LOCALE_ACTIONS update" shift 1 ;; --edit ) - ACTIONNAMS="$ACTIONNAMS locale_editMessages" + LOCALE_ACTIONS="$LOCALE_ACTIONS edit" shift 1 ;; --delete ) - ACTIONNAMS="$ACTIONNAMS locale_deleteMessages" - shift 1 - ;; - - --is-localizable ) - ACTIONNAMS="$ACTIONNAMS locale_isLocalizable" - shift 1 - ;; - - --dont-create-mo ) - FLAG_DONT_CREATE_MO="true" - shift 1 - ;; - - --synchronize ) - FLAG_SYNCHRONIZE="true" + LOCALE_ACTIONS="$LOCALE_ACTIONS delete" shift 1 ;; @@ -110,13 +84,8 @@ function locale_getOptions { esac done - # Verify action names. When no action name is specified, print an - # error message explaining an action is required at least. - if [[ $ACTIONNAMS == '' ]];then - cli_printMessage "`gettext "You need to provide one action at least."`" --as-error-line - fi - - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" + # Redefine arguments using current positional parameters. Only + # paths should remain as arguments, at this point. + TCAR_ARGUMENTS="${@}" } diff --git a/Automation/Modules/Locale/locale_isLocalizable.sh b/Automation/Modules/Locale/locale_isLocalizable.sh deleted file mode 100755 index f59bbe3..0000000 --- a/Automation/Modules/Locale/locale_isLocalizable.sh +++ /dev/null @@ -1,116 +0,0 @@ -#!/bin/bash -# -# locale_isLocalizable.sh -- This function determines whether a file -# or directory can have translation messages or not. This is the way -# we standardize what locations can and cannot be localized inside the -# repository. -# -# 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_isLocalizable { - - local DIR='' - local -a DIRS - - # Initialize location will use as reference to determine whether - # it can have translation messages or not. - local LOCATION="$1" - - # Initialize answer value. By default all paths do not accept - # localization. - local L10N_ACCEPTED='no' - - # When no variable is passed to this function, use the action - # value instead. - if [[ $LOCATION == '' ]];then - LOCATION=${ACTIONVAL} - fi - - # Redefine location to be sure we'll always evaluate a directory, - # as reference location. - if [[ -f $LOCATION ]];then - LOCATION=$(dirname $LOCATION) - fi - - # Verify location existence. If it doesn't exist we cannot go on. - cli_checkFiles -e $LOCATION - - # Initialize possible messages this function would print out. - local -a MESSAGES - - # Define regular expression list of all directories inside the - # repository that can have translation. Try to keep regular - # expressions as simple as possible, so they can be understood by - # sed program. - DIRS[++((${#DIRS[*]}))]="${TCAR_WORKDIR}/Identity/Models/Themes/[[:alnum:]-]+/Distro/$(\ - cli_getPathComponent --release-pattern)/(Anaconda|Concept|Posters|Media)" - DIRS[++((${#DIRS[*]}))]="${TCAR_WORKDIR}/Documentation/Models/Docbook/[[:alnum:]-]+" - DIRS[++((${#DIRS[*]}))]="${TCAR_WORKDIR}/Documentation/Models/Svg/[[:alnum:]-]+" - DIRS[++((${#DIRS[*]}))]="${TCAR_WORKDIR}/Scripts/Bash" - - # Verify location passed as first argument against the list of - # directories that can have translation messages. By default, the - # location passed as first argument is considered as a location - # that cannot have translation messages until a positive answer - # says otherwise. - for DIR in ${DIRS[@]};do - - # Define the path part which is not present in the - # localizable directories. - local PATHDIFF=$(echo ${LOCATION} | sed -r "s,${DIR}/,,") - - # Define the path part that is present in the localizable - # directories. - local PATHSAME=$(echo ${LOCATION} | sed -r "s,/${PATHDIFF},,") - - # Initiate verification between location provided and - # localizable directories. - if [[ $LOCATION =~ "^$DIR$" ]];then - - # At this point the location provided is exactly the same - # that matches the localizable directories. There is - # nothing else to do here but return the script flow to - # this function caller. - L10N_ACCEPTED='yes' - break - - elif [[ ${PATHSAME} =~ "^${DIR}" ]] && [[ -d ${LOCATION} ]];then - - # At this point the location provided is a directory in - # the repository which doesn't match any localizable - # directory in the list, but it could be rendered if the - # --filter option is provided with the appropriate path - # argument. Print a suggestion about it. - cli_printMessage "${PATHSAME} --filter=\"$PATHDIFF\"" --as-suggestion-line - break - - fi - - done - - # At this point, we are safe to say that the path provided isn't - # allow to have any localization for it. So, finish the script - # execution with an error message. - if [[ $L10N_ACCEPTED == 'no' ]];then - cli_printMessage "`gettext "The path provided doesn't support localization."`" --as-error-line - fi - -} diff --git a/Automation/Modules/Locale/locale_prepareWorkingDirectory.sh b/Automation/Modules/Locale/locale_prepareWorkingDirectory.sh deleted file mode 100755 index 0eaae6a..0000000 --- a/Automation/Modules/Locale/locale_prepareWorkingDirectory.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash -# -# locale_prepareWorkingDirectory.sh -- This function prepares the -# working directory where translation files should be stored. -# -# 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_prepareWorkingDirectory { - - local L10N_WORKDIR=$1 - - if [[ ! -d ${L10N_WORKDIR} ]];then - - # Create localization working directory making parent - # directories as needed. Subversion doesn't create directories - # recursively, so we use the system's `mkdir' command and then - # subversion to register the changes. - mkdir -p ${L10N_WORKDIR} - - # Commit changes from working copy to central repository only. - # At this point, changes in the repository are not merged in - # the working copy, but chages in the working copy do are - # committed up to central repository. - cli_synchronizeRepoChanges "${L10N_BASEDIR}" - - elif [[ $L10N_WORKDIR == '' ]];then - - cli_printMessage "`gettext "The localization directory isn't defined."`" --as-error-line - - fi - -} diff --git a/Automation/Modules/Locale/locale_setLocaleType.sh b/Automation/Modules/Locale/locale_setLocaleType.sh new file mode 100755 index 0000000..08049cb --- /dev/null +++ b/Automation/Modules/Locale/locale_setLocaleType.sh @@ -0,0 +1,81 @@ +#!/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_TYPE=$(tcar_getConfigValue "${CONFIGURATION}" "${SECTION}" "render-type") + + 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 + + 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 + + # Initialize locale's modules. + tcar_setModuleEnvironment "${RENDER_TYPE}" "${@}" + + # 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/locale_updateMessageBinary.sh b/Automation/Modules/Locale/locale_updateMessageBinary.sh index 426eb5d..7085e97 100755 --- a/Automation/Modules/Locale/locale_updateMessageBinary.sh +++ b/Automation/Modules/Locale/locale_updateMessageBinary.sh @@ -33,22 +33,10 @@ function locale_updateMessageBinary { # Define absolute path to final portable object. This is the file # that contains all the individual function translation messages # and is used to build the machine object (.mo) file. - local PO_FILE=${L10N_WORKDIR}/${TEXTDOMAIN}.po - - # Define list of portable objects to work with. This list must be - # built using the portable objects inside the working copy as - # reference not the information in the central repository - # (IMPORTANT: all of them must be included in this list, so - # FLAG_FILTER mustn't be applied here). Thus, when we are - # selective about the functionalities we want to use, it is - # possible to have translation messages only for those - # functionalities we did download into the working copy and no - # others. There is no need to have translation messages for - # functionalities we didn't download. - local PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --type='f' --pattern="^.+/messages.po$") + local PO_FILE=${TRANSLATION[0]} # Define absolute path to machine object directory. - local MO_DIR="${L10N_WORKDIR}/LC_MESSAGES" + local MO_DIR="$(dirame ${CONFIGURATION})/${TCAR_SCRIPT_LANG_LC}/LC_MESSAGES" # Define absolute path to machine object file. local MO_FILE="${MO_DIR}/${TEXTDOMAIN}.mo" diff --git a/Automation/Modules/Locale/locale_updateMessageMetadata.sh b/Automation/Modules/Locale/locale_updateMessageMetadata.sh index a986483..72f539e 100755 --- a/Automation/Modules/Locale/locale_updateMessageMetadata.sh +++ b/Automation/Modules/Locale/locale_updateMessageMetadata.sh @@ -1,16 +1,20 @@ #!/bin/bash +###################################################################### # -# locale_updateMessageMetadata.sh -- This function sanitates .pot and -# .po files to use common translation markers inside top comment. -# Later, replacement of common translation markers is applied to set -# the final information. +# locale_updateMessageMetadata.sh -- This function sanitates .pot +# and .po files to use common translation markers inside top +# comment. Later, replacement of common translation markers is +# applied to set the final information. +# +# 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. +# 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 @@ -21,9 +25,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function locale_updateMessageMetadata { @@ -31,11 +33,11 @@ function locale_updateMessageMetadata { local -a SRC local -a DST - # Retrive absolute path of portable object we'll work with. - local FILE="$1" + # Retrieve absolute path of portable object we'll work with. + local PO="${1}" # Check existence of file before work with it. - cli_checkFiles -e "${FILE}" + tcar_checkFiles "${PO}" -f # Define pattern lines. The pattern lines are put inside portable # objects through xgettext and xml2po commands. In the case of @@ -45,20 +47,20 @@ function locale_updateMessageMetadata { # their name each time they edit a file. SRC[0]="\"Project-Id-Version:" SRC[1]="\"Report-Msgid-Bugs-To:" - SRC[2]="\"Last-Translator: (Documentation SIG)?" + SRC[2]="\"Last-Translator: (.+)?" SRC[3]="\"Language-Team:" SRC[4]="\"PO-Revision-Date:" # Define replacement lines for pattern line. - DST[0]="\"Project-Id-Version: ${CLI_NAME}-${CLI_VERSION}\\\n\"" - DST[1]="\"Report-Msgid-Bugs-To: Documentation SIG <$(cli_printMailingList --docs)>\\\n\"" - DST[2]="\"Last-Translator: Documentation SIG\\\n\"" + DST[0]="\"Project-Id-Version: ${TCAR_SCRIPT_NAME} ${TCAR_SCRIPT_VERSION}\\\n\"" + DST[1]="\"Report-Msgid-Bugs-To: Documentation SIG \\\n\"" + DST[2]="\"Last-Translator: Documentation SIG \\\n\"" DST[3]="\"Language-Team: $(locale_getLanguageName)\\\n\"" DST[4]="\"PO-Revision-Date: $(date "+%F %H:%M%z")\\\n\"" # Change pattern lines with their replacement lines. while [[ $COUNT -lt ${#SRC[*]} ]];do - sed -i -r "/${SRC[$COUNT]}/c${DST[$COUNT]}" ${FILE} + sed -i -r "/${SRC[$COUNT]}/c${DST[$COUNT]}" ${PO} COUNT=$(($COUNT + 1)) done @@ -67,13 +69,13 @@ function locale_updateMessageMetadata { # does when xgettext is used. So, in order to have such metadata # field in all .pot files, verify its existence and add it if it # doesn't exist. - egrep "^\"${SRC[1]}" $FILE > /dev/null + egrep "^\"${SRC[1]}" ${PO} > /dev/null if [[ $? -ne 0 ]];then - sed -i -r "/^\"${SRC[0]}/a${DST[1]}" $FILE + sed -i -r "/^\"${SRC[0]}/a${DST[1]}" ${PO} fi # Replace package information using gettext domain information. - sed -i -r "s/PACKAGE/${CLI_NAME}-${CLI_VERSION}/g" ${FILE} + sed -i -r "s/PACKAGE/${TCAR_SCRIPT_NAME} ${TCAR_SCRIPT_VERSION}/g" ${PO} # Remove absolute path to the working copy so it doesn't appear on # comments related to locations. Remember that people can download @@ -81,7 +83,7 @@ function locale_updateMessageMetadata { # version those changes each time a translation message be # updated. To be consistent about this, show path information from # first level on. Don't show the variable part of the path. - sed -i -r "s,${TCAR_WORKDIR}/,,g" ${FILE} + sed -i -r "s,${TCAR_BASEDIR}/,,g" ${PO} # Unset array variables to avoid undesired concatenations. unset SRC diff --git a/Automation/Modules/Locale/locale_updateMessagePObjects.sh b/Automation/Modules/Locale/locale_updateMessagePObjects.sh index d2e9aa0..b93f51c 100755 --- a/Automation/Modules/Locale/locale_updateMessagePObjects.sh +++ b/Automation/Modules/Locale/locale_updateMessagePObjects.sh @@ -1,10 +1,14 @@ #!/bin/bash +###################################################################### # -# locale_updateMessagePObjects.sh -- This function initializes the -# portable object when it doesn't exist. When the portable object does -# exist, it is updated instead. In both cases, the portable object -# template is used as source to merge changes inside the portable -# object. +# Modules/Locale/locale_updateMessagePObjects.sh -- This function +# initializes the portable object when it doesn't exist. When the +# portable object does exist, it is updated instead. In both cases, +# the portable object template is used as source to merge changes +# inside the portable object. +# +# Written by: +# * Alain Reguera Delgado # # Copyright (C) 2009-2013 The CentOS Project # @@ -22,41 +26,41 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function locale_updateMessagePObjects { - local FILE="$1" + local POT="$1" # Verify the portable object template. The portable object # template is used to create the portable object. We cannot # continue without it. - cli_checkFiles -e "${FILE}.pot" + tcar_checkFiles "${POT}" -f + + PO=$(dirname ${TRANSLATIONS[0]})/messages.po # Print action message. - cli_printMessage "${FILE}.po" --as-creating-line + tcar_printMessage "${PO}" --as-creating-line # Verify existence of portable object. The portable object is the # file translators edit in order to make translation works. - if [[ -f ${FILE}.po ]];then + if [[ -f ${PO} ]];then # Update portable object merging both portable object and # portable object template. - msgmerge --output="${FILE}.po" "${FILE}.po" "${FILE}.pot" --quiet + msgmerge --output="${PO}" "${PO}" "${POT}" --quiet else # Initiate portable object using portable object template. # Do not print msginit sterr output, use centos-art action # message instead. - msginit -i ${FILE}.pot -o ${FILE}.po --width=70 \ + msginit -i ${POT} -o ${PO} --width=70 \ --no-translator > /dev/null 2>&1 fi # Sanitate metadata inside the PO file. - locale_updateMessageMetadata "${FILE}.po" + locale_updateMessageMetadata "${PO}" } diff --git a/Automation/Modules/Locale/locale_updateMessages.sh b/Automation/Modules/Locale/locale_updateMessages.sh index 32fd78d..d397dcf 100755 --- a/Automation/Modules/Locale/locale_updateMessages.sh +++ b/Automation/Modules/Locale/locale_updateMessages.sh @@ -1,18 +1,21 @@ #!/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). +# 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. +# 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 @@ -23,57 +26,28 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function locale_updateMessages { - # Verify directory passed as non-option argument to be sure it - # supports localization. - locale_isLocalizable "${ACTIONVAL}" - - # Prepare working directory to receive translation files. Don't - # do this here. This location can be redefine later based on - # deeper directory structures not provided as arguments to - # centos-art.sh script. For example, if you execute the following - # command: - # - # centos-art locale Documentation/Models/Svg/Brands --update - # - # it should produce the following directory structure: - # - # Locales/Documentation/Models/Svg/Brands/Logos/${LANG}/ - # Locales/Documentation/Models/Svg/Brands/Symbols/${LANG}/ - # Locales/Documentation/Models/Svg/Brands/Types/${LANG}/ - # - # and not the next one: - # - # Locales/Documentation/Models/Svg/Brands/${LANG}/ - # - # So, don't prepare working directory to receive translation files - # here. Instead, do it just before POT files creation. + case ${RENDER_TYPE} in - # Evaluate action value to determine whether to use xml2po to - # extract translatable strings from XML-based files or to use - # xgettext to extract translatable strings from shell script - # files. - if [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/(Documentation/Models/(Docbook|Svg)|Identity/Models)/.*$" ]];then + 'svg' ) + locale_convertSvgToPo + ;; - # Update translatable strings inside the portable object - # template related to XML-based files (e.g., scalable vector - # graphics). - locale_updateMessageXml + 'asciidoc' ) + locale_convertAsciidocToPo + ;; - elif [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/Scripts/Bash$" ]];then + 'sh' ) + locale_convertShellToPo + ;; - # Update translatable strings inside the portable object - # template related to shell scripts (e.g., the centos-art.sh - # script). - locale_updateMessageShell + * ) + cli_printMessage "`gettext "Couldn't find a valid render-type."`" --as-error-line + ;; - else - cli_printMessage "`gettext "The path provided doesn't support localization."`" --as-error-line - fi + esac } diff --git a/Automation/Scripts/tcar_printHelp.sh b/Automation/Scripts/tcar_printHelp.sh index 17c8750..b53da16 100755 --- a/Automation/Scripts/tcar_printHelp.sh +++ b/Automation/Scripts/tcar_printHelp.sh @@ -28,7 +28,7 @@ function tcar_printHelp { - /usr/bin/man -M ${MODULE_DIR_MANUALS} "${MODULE_NAME}" + /usr/bin/man -M ${TCAR_SCRIPT_BASEDIR}/Manuals/ "centos-art.sh-${MODULE_NAME}" exit 0 } diff --git a/Automation/Scripts/tcar_printMessage.sh b/Automation/Scripts/tcar_printMessage.sh index fa7d604..89e4ea0 100755 --- a/Automation/Scripts/tcar_printMessage.sh +++ b/Automation/Scripts/tcar_printMessage.sh @@ -242,6 +242,10 @@ function tcar_printMessage { tcar_printMessage "`gettext "Combining"`: ${MESSAGE}" --as-stdout-line ;; + --as-editing-line ) + tcar_printMessage "`gettext "Editing"`: ${MESSAGE}" --as-stdout-line + ;; + --as-creating-line | --as-updating-line ) if [[ -a "${MESSAGE}" ]];then tcar_printMessage "`gettext "Updating"`: ${MESSAGE}" --as-stdout-line diff --git a/Automation/centos-art.conf.sh b/Automation/centos-art.conf.sh index 8ad3a4e..88f1e30 100755 --- a/Automation/centos-art.conf.sh +++ b/Automation/centos-art.conf.sh @@ -122,7 +122,7 @@ declare -x TCAR_MANUAL_READER="/usr/bin/man -M ${TCAR_MANUAL_SEARCHPATH}" # will be use when you need to write commit messages and anything that # requires text edition. # -declare -x TCAR_USER_EDITOR=/bin/vi +declare -x TCAR_USER_EDITOR=/usr/bin/vim # # Set user-specific configuration file used by centos-art.sh script to # determine where to retrieve user-specific configuration values.