Blame Automation/Modules/centos-art.sh-locale/locale_updateMessageXmlDocbookWithEntities.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# locale_updateMessageXmlDocbookWithEntities.sh -- This function
Alain Reguera Delgado 8f60cb
# creates an instance of Docbook main file, expands entities inside
Alain Reguera Delgado 8f60cb
# it, retrieves all translatable strings from main file instance, and
Alain Reguera Delgado 8f60cb
# creates the related portable object template POT for them.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# Copyright (C) 2009-2013 The CentOS Project
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado 8f60cb
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado 8f60cb
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado 8f60cb
# your option) any later version.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado 8f60cb
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado 8f60cb
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado 8f60cb
# General Public License for more details.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado 8f60cb
# along with this program; if not, write to the Free Software
Alain Reguera Delgado 8f60cb
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
# $Id$
Alain Reguera Delgado 8f60cb
# ----------------------------------------------------------------------
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
function locale_updateMessageXmlDocbookWithEntities {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define location of the file used to create both portable object
Alain Reguera Delgado 8f60cb
    # templates (.pot) and portable objects (.po) files.
Alain Reguera Delgado 8f60cb
    local MESSAGES="${L10N_WORKDIR}/messages"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Print action message.
Alain Reguera Delgado 8f60cb
    cli_printMessage "${MESSAGES}.pot" --as-updating-line
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define file name used as template instance. Here is where we
Alain Reguera Delgado 8f60cb
    # expand translation markers and entities before retrieving
Alain Reguera Delgado 8f60cb
    # translation messages.
Alain Reguera Delgado 8f60cb
    local INSTANCE=$(cli_getTemporalFile "$(basename ${TEMPLATE})")
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create the non-translated instance of design model.
Alain Reguera Delgado 8f60cb
    cp ${TEMPLATE} ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Expand common contents inside instance.
Alain Reguera Delgado 8f60cb
    cli_exportFunctions "Render/Docbook/docbook_setExpansionLicenses"
Alain Reguera Delgado 8f60cb
    docbook_setExpansionLicenses ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # When translated instances are rendered, system entities (e.g.,
Alain Reguera Delgado 8f60cb
    # `%entity-name;') don't appear in the translated instance (it
Alain Reguera Delgado 8f60cb
    # seems that xml2po removes them) and this provokes DocBook
Alain Reguera Delgado 8f60cb
    # validation to fail.  So in order to pass the validation
Alain Reguera Delgado 8f60cb
    # successfully and automate the whole creation of system entities,
Alain Reguera Delgado 8f60cb
    # don't let this duty ion users'. Instead, make centos-art.sh
Alain Reguera Delgado 8f60cb
    # script responsible of it.
Alain Reguera Delgado 8f60cb
    cli_exportFunctions "Render/Docbook/docbook_setExpansionSystemEntities"
Alain Reguera Delgado 8f60cb
    docbook_setExpansionSystemEntities ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create portable object template from instance.  Validate
Alain Reguera Delgado 8f60cb
    # translated instance before processing it. This step is very
Alain Reguera Delgado 8f60cb
    # important in order to detect document's malformations and warn
Alain Reguera Delgado 8f60cb
    # you about it, so you can correct them. 
Alain Reguera Delgado 8f60cb
    xmllint --valid --noent ${INSTANCE} | xml2po -a -l ${CLI_LANG_LC} - \
Alain Reguera Delgado 8f60cb
        | msgcat --output=${MESSAGES}.pot \
Alain Reguera Delgado 8f60cb
                 --width=70 --no-location -
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Expand translation markers inside file.
Alain Reguera Delgado 8f60cb
    cli_expandTMarkers ${INSTANCE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify, initialize or merge portable objects from portable
Alain Reguera Delgado 8f60cb
    # object templates.
Alain Reguera Delgado 8f60cb
    locale_updateMessagePObjects "${MESSAGES}"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}