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
#
0bd190
# Copyright (C) 2009-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
# ----------------------------------------------------------------------
0bd190
# $Id: locale_updateMessageXml.sh 5457 2012-09-11 18:56:18Z al $
0bd190
# ----------------------------------------------------------------------
0bd190
0bd190
function locale_updateMessageXmlDocbook {
0bd190
0bd190
    # Print action message.
0bd190
    cli_printMessage "${MESSAGES}.pot" --as-updating-line
0bd190
0bd190
    # Define absolute path to Docbook's main file. This file must have
0bd190
    # the same name all in lowercase than its parent directory.
0bd190
    local TEMPLATE=${ACTIONVAL}/$(cli_getRepoName $(basename ${ACTIONVAL}) -f).docbook
0bd190
0bd190
    # Verify existence of docbook's main template file. We cannot go
0bd190
    # on without it.
0bd190
    cli_checkFiles ${TEMPLATE}
0bd190
0bd190
    # Define file name used as template instance. Here is where we
0bd190
    # expand translation markers and entities before retriving
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.
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.
0bd190
    ln -s ${TCAR_WORKDIR}/trunk/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
0bd190
    # Move out to initail location.
0bd190
    popd > /dev/null
0bd190
0bd190
    # Remove instance.
0bd190
    rm ${INSTANCE}
0bd190
0bd190
}