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

0bd190
#!/bin/bash
0bd190
#
0bd190
# locale_updateMessageXmlDocbook.sh -- This function retrives
0bd190
# translation messages from Docbook files and creates related portable
0bd190
# object template for them.
0bd190
#
5e8996
# Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project
0bd190
#
0bd190
# This program is free software; you can redistribute it and/or modify
0bd190
# it under the terms of the GNU General Public License as published by
0bd190
# the Free Software Foundation; either version 2 of the License, or (at
0bd190
# your option) any later version.
0bd190
#
0bd190
# This program is distributed in the hope that it will be useful, but
0bd190
# WITHOUT ANY WARRANTY; without even the implied warranty of
0bd190
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0bd190
# General Public License for more details.
0bd190
#
0bd190
# You should have received a copy of the GNU General Public License
0bd190
# along with this program; if not, write to the Free Software
0bd190
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
0bd190
#
0bd190
# ----------------------------------------------------------------------
e94a3a
# $Id$
0bd190
# ----------------------------------------------------------------------
0bd190
0bd190
function locale_updateMessageXmlDocbook {
0bd190
0bd190
    # Print action message.
0bd190
    cli_printMessage "${MESSAGES}.pot" --as-updating-line
0bd190
096bac
    # Define regular expression to match extensions of shell scripts
096bac
    # we use inside the repository.
096bac
    local EXTENSION='docbook'
096bac
096bac
    # Define absolute paths to Docbook main file.
096bac
    local TEMPLATE=$(cli_getFilesList ${ACTIONVAL} \
096bac
        --maxdepth=1 --mindepth=1 --type='f' \
096bac
        --pattern="$(cli_getRepoName ${ACTIONVAL} -f)\.${EXTENSION}$")
0bd190
0bd190
    # Verify existence of docbook's main template file. We cannot go
0bd190
    # on without it.
e94a3a
    cli_checkFiles -e ${TEMPLATE}
0bd190
0bd190
    # Define file name used as template instance. Here is where we
819c26
    # expand translation markers and entities before retrieving
0bd190
    # translation messages.
0bd190
    local INSTANCE=$(cli_getTemporalFile "$(basename ${TEMPLATE})")
0bd190
0bd190
    # Create instance from docbook's main file.
0bd190
    cp ${TEMPLATE} ${INSTANCE}
0bd190
0bd190
    # Expand translation markers inside instance.
0bd190
    cli_expandTMarkers ${INSTANCE}
0bd190
0bd190
    # Expand system entities definition.
297654
    cli_exportFunctions "Render/Docbook/docbook_doTranslation"
297654
    docbook_doTranslation ${INSTANCE}
297654
297654
    # Expand system entities definition.
0bd190
    cli_exportFunctions "Render/Docbook/docbook_expandSystemEntities"
0bd190
    docbook_expandSystemEntities ${INSTANCE}
0bd190
0bd190
    # Expand license block.
0bd190
    cli_exportFunctions "Render/Docbook/docbook_expandLicenses"
0bd190
    docbook_expandLicenses ${INSTANCE}
0bd190
0bd190
    # Create link to `Images' directory for validation to pass.
0bd190
    # Otherwise, a validation error is reported because no path was
0bd190
    # found to images.
819c26
    ln -s ${TCAR_WORKDIR}/Identity/Images/Webenv $(dirname ${INSTANCE})/Images
0bd190
0bd190
    # Move into temporal directory so paths can be found relatively.
0bd190
    pushd $(dirname ${INSTANCE}) > /dev/null
0bd190
0bd190
    # Create portable object template from instance.
0bd190
    xmllint --valid --noent ${INSTANCE} | xml2po -a - \
0bd190
        | msgcat --output=${MESSAGES}.pot --width=70 --no-location -
0bd190
819c26
    # Move out to initial location.
0bd190
    popd > /dev/null
0bd190
0bd190
    # Remove instance.
0bd190
    rm ${INSTANCE}
0bd190
0bd190
}