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

4e4b4d
#!/bin/bash
4e4b4d
#
4e4b4d
# locale_updateMessageMetadata.sh -- This function sanitates .pot and
4e4b4d
# .po files to use common translation markers inside top comment.
4e4b4d
# Later, replacement of common translation markers is applied to set
4e4b4d
# the final information.
4e4b4d
#
4e4b4d
# Copyright (C) 2009-2011 Alain Reguera Delgado
4e4b4d
# 
4e4b4d
# This program is free software; you can redistribute it and/or
4e4b4d
# modify it under the terms of the GNU General Public License as
4e4b4d
# published by the Free Software Foundation; either version 2 of the
4e4b4d
# License, or (at your option) any later version.
4e4b4d
# 
4e4b4d
# This program is distributed in the hope that it will be useful, but
4e4b4d
# WITHOUT ANY WARRANTY; without even the implied warranty of
4e4b4d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4e4b4d
# General Public License for more details.
4e4b4d
#
4e4b4d
# You should have received a copy of the GNU General Public License
4e4b4d
# along with this program; if not, write to the Free Software
4e4b4d
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4e4b4d
# USA.
4e4b4d
# 
4e4b4d
# ----------------------------------------------------------------------
4e4b4d
# $Id4
4e4b4d
# ----------------------------------------------------------------------
4e4b4d
4e4b4d
function locale_updateMessageMetadata {
4e4b4d
4e4b4d
    local COUNT=0
4e4b4d
    local -a SRC
4e4b4d
    local -a DST
4e4b4d
4e4b4d
    # Retrive absolute path of portable object we'll work with.
4e4b4d
    local FILE="$1"
4e4b4d
4e4b4d
    # Define current locale.
4e4b4d
    local CURRENTLOCALE=$(cli_getCurrentLocale)
4e4b4d
4e4b4d
    # Define language name from current locale.
4e4b4d
    local LANGNAME=$(cli_getLangName ${CURRENTLOCALE})
4e4b4d
4e4b4d
    # Check existence of file before work with it.
4e4b4d
    cli_checkFiles "${FILE}" 'f'
4e4b4d
bf6bff
    # Define pattern lines. The pattern lines are put inside portable
bec0a3
    # objects through xgettext and xml2po commands .
4e4b4d
    SRC[0]='Project-Id-Version:'
bec0a3
    SRC[1]='Report-Msgid-Bugs-To:'
bec0a3
    SRC[2]='Last-Translator:'
bec0a3
    SRC[3]='Language-Team:'
4e4b4d
bf6bff
    # Define replacement lines for pattern line.
7b46a4
    DST[0]="\"Project-Id-Version: ${CLI_PROGRAM} (${CURRENTLOCALE})\\\n\""
bec0a3
    DST[1]="\"Report-Msgid-Bugs-To: =MAIL_DOCS=\\\n\""
bec0a3
    DST[2]="\"Last-Translator: CentOS Documentation SIG\\\n\""
bec0a3
    DST[3]="\"Language-Team: ${LANGNAME}\\\n\""
4e4b4d
bec0a3
    # Change pattern lines with their replacement lines.
4e4b4d
    while [[ $COUNT -lt ${#SRC[*]} ]];do
4e4b4d
        sed -i -r "/${SRC[$COUNT]}/c${DST[$COUNT]}" ${FILE}
4e4b4d
        COUNT=$(($COUNT + 1))
4e4b4d
    done
4e4b4d
bec0a3
    # Replace package information using gettext domain information.
bec0a3
    sed -i -r "s/PACKAGE/${TEXTDOMAIN}/g" ${FILE}
bec0a3
4e4b4d
    # Unset array variables to avoid undesired concatenations.
4e4b4d
    unset SRC
4e4b4d
    unset DST
4e4b4d
4e4b4d
}