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 52ee2e
    local PO_FILE=${TRANSLATION[0]}
Alain Reguera Delgado 8f60cb
Alain Reguera Delgado 8f60cb
    # Define absolute path to machine object directory.
Alain Reguera Delgado 52ee2e
    local MO_DIR="$(dirame ${CONFIGURATION})/${TCAR_SCRIPT_LANG_LC}/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
}