Blame Scripts/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
fa95b1
#
fa95b1
# This program is free software; you can redistribute it and/or modify
fa95b1
# it under the terms of the GNU General Public License as published by
dcd347
# the Free Software Foundation; either version 2 of the License, or (at
dcd347
# your option) any later version.
fa95b1
#
74a058
# This program is distributed in the hope that it will be useful, but
74a058
# 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
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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
}