Blame Automation/Modules/Locale/locale_updateMessageBinary.sh

Alain Reguera Delgado 8f60cb
#!/bin/bash
Alain Reguera Delgado 8f60cb
#
Alain Reguera Delgado 8f60cb
# locale_updateMessageBinary.sh -- This function creates/updates
Alain Reguera Delgado 8f60cb
# machine objects (.mo) from portable objects (.po).
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_updateMessageBinary {
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify machine object creation flag.
Alain Reguera Delgado 8f60cb
    if [[ ${FLAG_DONT_CREATE_MO} == 'true' ]];then
Alain Reguera Delgado 8f60cb
        return
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to final portable object. This is the file
Alain Reguera Delgado 8f60cb
    # that contains all the individual function translation messages
Alain Reguera Delgado 8f60cb
    # and is used to build the machine object (.mo) file.
Alain Reguera Delgado 8f60cb
    local PO_FILE=${L10N_WORKDIR}/${TEXTDOMAIN}.po
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define list of portable objects to work with. This list must be
Alain Reguera Delgado 8f60cb
    # built using the portable objects inside the working copy as
Alain Reguera Delgado 8f60cb
    # reference not the information in the central repository
Alain Reguera Delgado 8f60cb
    # (IMPORTANT: all of them must be included in this list, so
Alain Reguera Delgado 8f60cb
    # FLAG_FILTER mustn't be applied here). Thus, when we are
Alain Reguera Delgado 8f60cb
    # selective about the functionalities we want to use, it is
Alain Reguera Delgado 8f60cb
    # possible to have translation messages only for those
Alain Reguera Delgado 8f60cb
    # functionalities we did download into the working copy and no
Alain Reguera Delgado 8f60cb
    # others. There is no need to have translation messages for
Alain Reguera Delgado 8f60cb
    # functionalities we didn't download.
Alain Reguera Delgado 8f60cb
    local PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --type='f' --pattern="^.+/messages.po$")
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to machine object directory.
Alain Reguera Delgado 8f60cb
    local MO_DIR="${L10N_WORKDIR}/LC_MESSAGES"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to machine object file.
Alain Reguera Delgado 8f60cb
    local MO_FILE="${MO_DIR}/${TEXTDOMAIN}.mo"
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Print action message.
Alain Reguera Delgado 8f60cb
    cli_printMessage "${PO_FILE}" --as-creating-line
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Combine all the function individual portable objects into just
Alain Reguera Delgado 8f60cb
    # one portable object. Be sure to use just the first translation
Alain Reguera Delgado 8f60cb
    # found, otherwise the automated flow will be broken for you to
Alain Reguera Delgado 8f60cb
    # decide which one of two or more variants should remain in the
Alain Reguera Delgado 8f60cb
    # portable object.
Alain Reguera Delgado 8f60cb
    msgcat ${PO_FILES} --use-first --output-file=${PO_FILE}
Alain Reguera Delgado 8f60cb
    
Alain Reguera Delgado 8f60cb
    # Print action message.
Alain Reguera Delgado 8f60cb
    cli_printMessage "${MO_FILE}" --as-creating-line
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Verify absolute path to machine object directory, if it doesn't
Alain Reguera Delgado 8f60cb
    # exist create it.
Alain Reguera Delgado 8f60cb
    if [[ ! -d ${MO_DIR} ]];then
Alain Reguera Delgado 8f60cb
        mkdir -p ${MO_DIR}
Alain Reguera Delgado 8f60cb
    fi
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Create machine object from portable object.
Alain Reguera Delgado 8f60cb
    msgfmt --check ${PO_FILE} --output-file=${MO_FILE}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
}