Blame Scripts/Bash/centos-art/Functions/Locale/locale_updateMessagePObjects.sh

dbd41f
#!/bin/bash
dbd41f
#
dbd41f
# locale_updateMessagePObjects.sh --- This function verifies,
dbd41f
# initializes or updates portable objects from portable object
dbd41f
# templates.
dbd41f
#
dbd41f
# Copyright (C) 2009-2011 Alain Reguera Delgado
dbd41f
# 
dbd41f
# This program is free software; you can redistribute it and/or
dbd41f
# modify it under the terms of the GNU General Public License as
dbd41f
# published by the Free Software Foundation; either version 2 of the
dbd41f
# License, or (at your option) any later version.
dbd41f
# 
dbd41f
# This program is distributed in the hope that it will be useful, but
dbd41f
# WITHOUT ANY WARRANTY; without even the implied warranty of
dbd41f
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
dbd41f
# General Public License for more details.
dbd41f
#
dbd41f
# You should have received a copy of the GNU General Public License
dbd41f
# along with this program; if not, write to the Free Software
dbd41f
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
dbd41f
# USA.
dbd41f
# 
dbd41f
# ----------------------------------------------------------------------
dbd41f
# $Id$
dbd41f
# ----------------------------------------------------------------------
dbd41f
dbd41f
function locale_updateMessagePObjects {
dbd41f
dbd41f
    local FILE="$1"
dbd41f
dbd41f
    # Verify the portable object template. The portable object
dbd41f
    # template is used to create the portable object. 
fb5554
    cli_checkFiles "${FILE}.pot" 'f'
dbd41f
dbd41f
    # Verify existence of portable object. The portable object is the
dbd41f
    # file translators edit in order to make translation works.
dbd41f
    if [[ -f ${FILE}.po ]];then
dbd41f
dbd41f
        # Print action message.
dbd41f
        cli_printMessage "${FILE}.po" 'AsUpdatingLine'
dbd41f
dbd41f
        # Update portable object merging both portable object and
dbd41f
        # portable object template.
dbd41f
        msgmerge --output="${FILE}.po" "${FILE}.po" "${FILE}.pot" --quiet
dbd41f
dbd41f
    else
dbd41f
dbd41f
        # Print action message and initiate portable object using
dbd41f
        # portable object template.  There is no `--quiet' option for
dbd41f
        # msginit command that let to separate both printing action
dbd41f
        # message and creation command apart one from another so we
dbd41f
        # have to play with stderr and stdout outputs to print the
dbd41f
        # action message as we usually do.
dbd41f
        cli_printMessage $(msginit -i ${FILE}.pot -o ${FILE}.po --width=70 \
dbd41f
            --no-translator 2>&1 | cut -d' ' -f2 | sed -r 's!\.$!!') 'AsCreatingLine'
dbd41f
dbd41f
        # Sanitate portable object metadata. This is the first time
dbd41f
        # the portable object is created so some modifications are
dbd41f
        # needed to customized metadata.
dbd41f
        locale_updateMessageMetadata "${FILE}.po"
dbd41f
dbd41f
    fi
dbd41f
dbd41f
}