Blame Scripts/Functions/Locale/locale_updateMessageXml.sh

4e4b4d
#!/bin/bash
4e4b4d
#
0d4faa
# locale_updateMessageXml.sh -- This function parses XML-based files
0d4faa
# (e.g., scalable vector graphics), retrives translatable strings and
f4bdfd
# creates/update gettext portable objects.
4e4b4d
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# WITHOUT ANY WARRANTY; without even the implied warranty of
4e4b4d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4e4b4d
# General Public License for more details.
4e4b4d
#
4e4b4d
# You should have received a copy of the GNU General Public License
4e4b4d
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
4e4b4d
# ----------------------------------------------------------------------
4e4b4d
# $Id$
4e4b4d
# ----------------------------------------------------------------------
4e4b4d
4e4b4d
function locale_updateMessageXml {
4e4b4d
fef984
    # Print separator line.
510fad
    cli_printMessage '-' --as-separator-line
fef984
f4bdfd
    # Define filename used to create both portable object templates
f4bdfd
    # (.pot) and portable objects (.po) files.
5b7448
    local FILE="${WORKDIR}/messages"
f4bdfd
053779
    # Define regular expression to match extensions of XML files we
053779
    # use inside the repository.
6ca4b0
    local EXTENSION='(svg|xml|xhtml|docbook)'
053779
f6e184
    # Build list of files to process.  Remember that in some cases
f6e184
    # templates and output are in the same location (e.g., when
6c8081
    # rendering `trunk/Manuals/repository.xhtml/' directory). In these
f6e184
    # cases localized content are stored in the same location where
f6e184
    # template files are retrived from and we need to avoid using
f6e184
    # localized content from being interpreted as design models. In
f6e184
    # that sake, supress language-specific files from the list of
f6e184
    # files to process.
c2f150
    local FILES=$(cli_getFilesList ${ACTIONVAL} \
c2f150
        --pattern="${FLAG_FILTER}.*\.${EXTENSION}" \
c2f150
        --maxdepth='1' --type="f" \
f6e184
        | egrep -v '/[[:alpha:]]{2}_[[:alpha:]]{2}/')
0d4faa
4e4b4d
    # Print action message.
510fad
    cli_printMessage "${FILE}.pot" --as-updating-line
4e4b4d
c2f150
    # Normalize XML files and expand entities before retriving
c2f150
    # translatable strings and creating the portable object template
c2f150
    # (.pot).  The translatable strings are retrived from the
c2f150
    # normalized output of files, not files themselves (because of
c2f150
    # this, we don't include `#: filename:line' output on .pot files).
c2f150
    # Entity expansion is also necessary for DocBook documents to be
c2f150
    # processed correctly. Notice that some long DocBook document
c2f150
    # structures might use entities to split the document structure
c2f150
    # into smaller pieces so they could be easier to maintain.
c2f150
    xmllint --valid --noent ${FILES} | xml2po -a - \
c2f150
        | msgcat --output=${FILE}.pot --width=70 --no-location -
4e4b4d
f4bdfd
    # Verify, initialize or merge portable objects from portable
f4bdfd
    # object templates.
f4bdfd
    locale_updateMessagePObjects "${FILE}"
4e4b4d
c2f150
    # Commit changes from working copy to central repository only.  At
c2f150
    # this point, changes in the repository are not merged in the
c2f150
    # working copy, but chages in the working copy do are committed up
c2f150
    # to repository.
c2f150
    cli_commitRepoChanges "${L10N_BASEDIR}"
c2f150
4e4b4d
}