Blame Scripts/Functions/Locale/locale_updateMessagePObjects.sh

dbd41f
#!/bin/bash
dbd41f
#
80bc6f
# locale_updateMessagePObjects.sh -- This function initializes the
80bc6f
# portable object when it doesn't exist. When the portable object does
80bc6f
# exist, it is updated instead. In both cases, the portable object
80bc6f
# template is used as source to merge changes inside the portable
80bc6f
# object.
dbd41f
#
3b0984
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
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.
7ac5a5
#
dbd41f
# ----------------------------------------------------------------------
dbd41f
# $Id$
dbd41f
# ----------------------------------------------------------------------
dbd41f
dbd41f
function locale_updateMessagePObjects {
dbd41f
dbd41f
    local FILE="$1"
dbd41f
dbd41f
    # Verify the portable object template. The portable object
80bc6f
    # template is used to create the portable object. We cannot
80bc6f
    # continue without it. 
a7615e
    cli_checkFiles "${FILE}.pot"
dbd41f
80bc6f
    # Print action message.
80bc6f
    cli_printMessage "${FILE}.po" --as-creating-line
80bc6f
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
        # 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
        # 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.
80bc6f
        ${FUNCNAM}_updateMessageMetadata "${FILE}.po"
dbd41f
dbd41f
    fi
dbd41f
dbd41f
}