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

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# locale_updateMessageXmlDocbookNoEntities.sh -- This function creates
Alain Reguera Delgado 8f60cb
# an instance of one or more Docbook files without expanding entities
Alain Reguera Delgado 8f60cb
# inside it, retrieves all translatable strings from main file
Alain Reguera Delgado 8f60cb
# instance, and creates the related portable object template POT for
Alain Reguera Delgado 8f60cb
# them. This is useful to localize Docbook files that aren't direct
Alain Reguera Delgado 8f60cb
# part of a documentation manual but included at rendition time (e.g.,
Alain Reguera Delgado 8f60cb
# Docbook files holding license information).
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_updateMessageXmlDocbookNoEntities {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # In case no path to Docbook main file is not found, go deeper
Alain Reguera Delgado 8f60cb
    # into the documentation models directory structure looking for
Alain Reguera Delgado 8f60cb
    # files that do match the name of the directory who hold it, and
Alain Reguera Delgado 8f60cb
    # use that file as template to initiate localization process. The
Alain Reguera Delgado 8f60cb
    # way to reach these files have to be through --filter options
Alain Reguera Delgado 8f60cb
    # because we want to respect the restrictions imposed by
Alain Reguera Delgado 8f60cb
    # locale_isLocalizable function inside the repository.
Alain Reguera Delgado 8f60cb
    # CAUTION: entity expansion the files found this way will be # ignored.
Alain Reguera Delgado 8f60cb
    local TEMPLATES=$(cli_getFilesList ${ACTIONVAL} --type='f' \
Alain Reguera Delgado 8f60cb
        --pattern=".+/${FLAG_FILTER}.+\.${EXTENSION}$")
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify number of template files found and define what kind of
Alain Reguera Delgado 8f60cb
    # processing they are going to have. In case more than one
Alain Reguera Delgado 8f60cb
    # template file be found and because entity expansion will be
Alain Reguera Delgado 8f60cb
    # ignored in such case, the whole process of creating the PO file
Alain Reguera Delgado 8f60cb
    # for all these templates is also different (simpler) from that we
Alain Reguera Delgado 8f60cb
    # use with entity expansion.
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    for TEMPLATE in ${TEMPLATES};do
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Redefine path related to localization work directory.
Alain Reguera Delgado 8f60cb
        local L10N_WORKDIR=$(cli_getLocalizationDir "$TEMPLATE")
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
        # Define location of the file used to create both portable
Alain Reguera Delgado 8f60cb
        # object 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
        # Extract translatable strings from docbook files and merge
Alain Reguera Delgado 8f60cb
        # them down into related messages file.
Alain Reguera Delgado 8f60cb
        xml2po -a -l ${CLI_LANG_LL} -o ${MESSAGES}.pot ${TEMPLATE} 
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
    done
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}