Blame Scripts/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
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
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
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
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
3f6c79
        # Print action message.
3f6c79
        cli_printMessage "${FILE}.po" 'AsCreatingLine'
3f6c79
3f6c79
        # Initiate portable object using portable object template.
3f6c79
        # Do not print msginit sterr output, use centos-art action
3f6c79
        # message instead.
3f6c79
        msginit -i ${FILE}.pot -o ${FILE}.po --width=70 \
3f6c79
            --no-translator 2> /dev/null
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
}