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

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