Blame tcar-scripts-locale/Modules/Files/Modules/Update/update_convertPotToPo.sh

Alain Reguera Delgado f72cfe
#!/bin/bash
Alain Reguera Delgado f72cfe
######################################################################
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
#   update_convertPotToPo.sh -- This function takes a portable object
Alain Reguera Delgado f72cfe
#   template (.pot) and creates a language-specific portable object
Alain Reguera Delgado f72cfe
#   (.po) for it.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
#   Written by:
Alain Reguera Delgado f72cfe
#   * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# Copyright (C) 2009-2013 The CentOS Artwork SIG
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado f72cfe
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado f72cfe
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado f72cfe
# your option) any later version.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado f72cfe
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado f72cfe
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado f72cfe
# General Public License for more details.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado f72cfe
# along with this program; if not, write to the Free Software
Alain Reguera Delgado f72cfe
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado f72cfe
#
Alain Reguera Delgado f72cfe
######################################################################
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
function update_convertPotToPo {
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    local POT_FILE="${1}"
Alain Reguera Delgado f72cfe
    local PO_FILE="${2}"
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Verify the portable object template. The portable object
Alain Reguera Delgado f72cfe
    # template is used to create the portable object. We cannot
Alain Reguera Delgado f72cfe
    # continue without it.
Alain Reguera Delgado f72cfe
    tcar_checkFiles -ef ${POT_FILE}
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Print action message.
Alain Reguera Delgado f72cfe
    tcar_printMessage "${PO_FILE}" --as-creating-line
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Verify existence of portable object. The portable object is the
Alain Reguera Delgado f72cfe
    # file translators edit in order to make translation works.
Alain Reguera Delgado f72cfe
    if [[ -f ${PO_FILE} ]];then
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        # Update portable object merging both portable object and
Alain Reguera Delgado f72cfe
        # portable object template.
Alain Reguera Delgado f72cfe
        msgmerge --output-file="${PO_FILE}" "${PO_FILE}" "${POT_FILE}" --quiet
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    else
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        # Create the PO's parent directory if it doesn't exist.
Alain Reguera Delgado f72cfe
        if [[ ! -d $(dirname ${PO_FILE}) ]];then
Alain Reguera Delgado f72cfe
            mkdir -p $(dirname ${PO_FILE})
Alain Reguera Delgado f72cfe
        fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
        # Initiate portable object using portable object template.
Alain Reguera Delgado f72cfe
        # Do not print msginit sterr output, use centos-art action
Alain Reguera Delgado f72cfe
        # message instead.
Alain Reguera Delgado f72cfe
        msginit -i ${POT_FILE} -o ${PO_FILE} --width=70 \
Alain Reguera Delgado f72cfe
            --no-translator > /dev/null 2>&1
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    fi
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
    # Sanitate metadata inside the PO file.
Alain Reguera Delgado f72cfe
    update_setPoMetadata "${PO_FILE}"
Alain Reguera Delgado f72cfe
Alain Reguera Delgado f72cfe
}