Blame Functions/Locale/locale_updateMessageBinary.sh

b2e671
#!/bin/bash
b2e671
#
b2e671
# locale_updateMessageBinary.sh -- This function creates/updates
b2e671
# machine objects (.mo) from portable objects (.po).
b2e671
#
b2e671
# Copyright (C) 2009-2011 Alain Reguera Delgado
b2e671
# 
b2e671
# This program is free software; you can redistribute it and/or
b2e671
# modify it under the terms of the GNU General Public License as
b2e671
# published by the Free Software Foundation; either version 2 of the
b2e671
# License, or (at your option) any later version.
b2e671
# 
b2e671
# This program is distributed in the hope that it will be useful, but
b2e671
# WITHOUT ANY WARRANTY; without even the implied warranty of
b2e671
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
b2e671
# General Public License for more details.
b2e671
#
b2e671
# You should have received a copy of the GNU General Public License
b2e671
# along with this program; if not, write to the Free Software
b2e671
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
b2e671
# USA.
b2e671
# 
b2e671
# ----------------------------------------------------------------------
b2e671
# $Id$
b2e671
# ----------------------------------------------------------------------
b2e671
b2e671
function locale_updateMessageBinary {
b2e671
b2e671
    # Verify machine object creation flag.
0d4faa
    if [[ ${FLAG_DONT_CREATE_MO} == 'true' ]];then
b2e671
        return
b2e671
    fi
b2e671
b2e671
    local PO=''
b2e671
    local MO=''
b2e671
    local FILE=''
b2e671
    local FILES="$1"
b2e671
b2e671
    for FILE in $FILES;do
b2e671
b2e671
        # Verify existence of portable object.
b2e671
        cli_checkFiles "${FILE}" 'f'
b2e671
b2e671
        # Define absolute path to portable object.
b2e671
        PO=$FILE
b2e671
b2e671
        # Define absolute path to machine object.
b2e671
        MO=$(dirname ${PO})/LC_MESSAGES/$(basename ${PO} | sed -r 's!\.po$!.mo!')
b2e671
b2e671
        # Print action message.
bf6bff
        if [[ -f ${MO} ]];then
b2e671
            cli_printMessage "${MO}" 'AsUpdatingLine'
b2e671
        else
b2e671
            cli_printMessage "${MO}" 'AsCreatingLine'
b2e671
        fi
b2e671
b2e671
        # Define directory used to store machine object.
b2e671
        MODIR=$(dirname ${MO})
b2e671
bf6bff
        # Create directory to store machine object, if it doesn't
bf6bff
        # exist.
b2e671
        if [[ ! -d ${MODIR} ]];then
b2e671
            mkdir -p ${MODIR}
b2e671
        fi
b2e671
    
b2e671
        # Create machine object from portable object.
b2e671
        msgfmt --check ${PO} --output-file=${MO}
b2e671
b2e671
    done
b2e671
b2e671
}