Blame Scripts/Bash/Functions/Locale/locale_updateMessageXmlSvg.sh

fc7fa6
#!/bin/bash
fc7fa6
#
78487b
# locale_updateMessageXmlSvg.sh -- This function parses XML-based
78487b
# files (e.g., scalable vector graphics), retrieves translatable
78487b
# strings and creates/update gettext portable objects.
fc7fa6
#
78487b
# Copyright (C) 2009-2013 The CentOS Project
78487b
#
78487b
# This program is free software; you can redistribute it and/or modify
78487b
# it under the terms of the GNU General Public License as published by
78487b
# the Free Software Foundation; either version 2 of the License, or (at
78487b
# your option) any later version.
78487b
#
78487b
# This program is distributed in the hope that it will be useful, but
78487b
# WITHOUT ANY WARRANTY; without even the implied warranty of
78487b
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
78487b
# General Public License for more details.
78487b
#
78487b
# You should have received a copy of the GNU General Public License
78487b
# along with this program; if not, write to the Free Software
78487b
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
78487b
#
78487b
# ----------------------------------------------------------------------
78487b
# $Id$
78487b
# ----------------------------------------------------------------------
fc7fa6
fc7fa6
function locale_updateMessageXmlSvg {
fc7fa6
78487b
    # Inside `Identity/Models' and Documentation/Models/Svg/, design
78487b
    # models can be compressed or uncompressed. Because of this we
78487b
    # cannot process all the design models in one unique way. Instead,
78487b
    # we need to treat them individually based on their file type.
78487b
78487b
    local DIR=''
78487b
    local DIRS=''
78487b
78487b
    # Define regular expression to match extensions of shell scripts
78487b
    # we use inside the repository.
78487b
    local EXTENSION='(svgz|svg)'
78487b
78487b
    # Build list of directories in which we want to look files for.
78487b
    local DIRS=$(cli_getFilesList ${ACTIONVAL} \
78487b
        --pattern="${ACTIONVAL}/${FLAG_FILTER}")
78487b
78487b
    # Process list of directories, one by one.
78487b
    for DIR in $DIRS;do
fc7fa6
78487b
        # Reset information related to temporal files.
78487b
        local TEMPFILE=''
78487b
        local TEMPFILES=''
fc7fa6
78487b
        # Redefine localization working directory using the current
78487b
        # directory. The localization working directory is the place
78487b
        # where POT and PO files are stored inside the working copy.
78487b
        local L10N_WORKDIR=$(cli_getLocalizationDir "${DIR}")
fc7fa6
78487b
        # Prepare working directory to receive translation files.
78487b
        locale_prepareWorkingDirectory ${L10N_WORKDIR}
fc7fa6
78487b
        # Redefine final location of messages.po file, based on
78487b
        # current directory.
78487b
        MESSAGES=${L10N_WORKDIR}/messages
78487b
78487b
        # Build list of files we want to work with.
78487b
        FILES=$(cli_getFilesList ${DIR} --pattern="${DIR}/.+\.${EXTENSION}")
78487b
78487b
        for FILE in $FILES;do
78487b
78487b
            # Redefine temporal file based on file been processed.
78487b
            TEMPFILE=$(cli_getTemporalFile $(basename ${FILE}))
78487b
78487b
            # Update the command used to read content of XML files.
78487b
            if [[ $(file -b -i $FILE) =~ '^application/x-gzip$' ]];then
fc7fa6
        
78487b
                # Create uncompressed copy of file.
78487b
                /bin/zcat $FILE > $TEMPFILE
fc7fa6
78487b
            else
fc7fa6
                
78487b
                # Create uncompressed copy of file.
78487b
                /bin/cat $FILE > $TEMPFILE
fc7fa6
78487b
            fi
fc7fa6
78487b
            # Concatenate temporal files into a list so we can process
78487b
            # them later through xml2po, all at once.
78487b
            TEMPFILES="${TEMPFILE} ${TEMPFILES}"
fc7fa6
78487b
        done
78487b
78487b
        # Create the portable object template.
78487b
        cat $TEMPFILES | xml2po -a -l ${CLI_LANG_LC} - \
78487b
            | msgcat --output=${MESSAGES}.pot --width=70 --no-location -
fc7fa6
78487b
        # Verify, initialize or merge portable objects from portable
78487b
        # object templates.
78487b
        locale_updateMessagePObjects "${MESSAGES}"
fc7fa6
78487b
    done
fc7fa6
fc7fa6
}