Blame Scripts/Bash/Functions/Locale/locale_doMessagesStatus.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# locale_doMessagesStatus.sh -- This function outputs the
4c79b5
# centos-art.sh translations table. Use this function to know how many
4c79b5
# languages the centos-art.sh script is available in, the last
4c79b5
# translators and revision dates.
4c79b5
#
4c79b5
# Copyright (C) 2009-2010 Alain Reguera Delgado
4c79b5
# 
4c79b5
# This program is free software; you can redistribute it and/or modify
4c79b5
# it under the terms of the GNU General Public License as published by
4c79b5
# the Free Software Foundation; either version 2 of the License, or
4c79b5
# (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function locale_doMessagesStatus {
4c79b5
4c79b5
    # Define variables as local to avoid conflicts outside.
4c79b5
    local LOCALESLIST=''
4c79b5
    local LANG_NAME=''
4c79b5
    local LANG_COUNTRY=''
4c79b5
    local PO_LASTAUTHOR=''
4c79b5
    local PO_REVDATE=''
4c79b5
    local PO_STATUS=''
4c79b5
4c79b5
    # Define list of locale codes.
4c79b5
    LOCALESLIST=$(cli_getLocales) 
4c79b5
4c79b5
    for LOCALECODE in $LOCALESLIST;do
4c79b5
4c79b5
        LANG_NAME=$(cli_getLangName $LOCALECODE)
4c79b5
        LANG_COUNTRY=$(cli_getCountryName $LOCALECODE)
4c79b5
4c79b5
        if [[ -f $TEXTDOMAINDIR/$LOCALECODE/$TEXTDOMAIN.po ]] \
4c79b5
            && [[ -f $TEXTDOMAINDIR/$LOCALECODE/LC_MESSAGES/$TEXTDOMAIN.mo ]];then
4c79b5
4c79b5
            # Re-define translation's status.
4c79b5
            PO_STATUS="`gettext "Available"`"
4c79b5
4c79b5
            # Re-define translation's last update.
4c79b5
            PO_REVDATE=$(egrep '^"PO-Revision-Date:' $TEXTDOMAINDIR/$LOCALECODE/$TEXTDOMAIN.po \
4c79b5
                | cut -d: -f2- | sed -r 's!\\n"!!' | sed -r 's!^[[:space:]]+!!' | cut -d ' ' -f1)
4c79b5
4c79b5
            # Re-define translation's last author.
4c79b5
            PO_LASTAUTHOR=$(egrep '^"Last-Translator:' $TEXTDOMAINDIR/$LOCALECODE/$TEXTDOMAIN.po \
4c79b5
                | cut -d: -f2 | sed -r 's!\\n"!!' | sed -r 's!^[[:space:]]+!!')
4c79b5
4c79b5
        else
4c79b5
4c79b5
            LANGCOUNTRY=""
4c79b5
            PO_LASTAUTHOR=""
4c79b5
            PO_REVDATE=""
4c79b5
            PO_STATUS=""
4c79b5
4c79b5
        fi
4c79b5
4c79b5
        # Output information line.
4c79b5
        echo "$LOCALECODE | $LANG_NAME | $LANG_COUNTRY | $PO_STATUS | $PO_REVDATE | $PO_LASTAUTHOR"
4c79b5
4c79b5
    done \
4c79b5
        | egrep -i $REGEX \
4c79b5
        | awk 'BEGIN {FS="|"; format ="%7s\t%-15s\t%-15s\t%-12s\t%-12s\t%-s\n"
4c79b5
                      printf "--------------------------------------------------------------------------------\n"
4c79b5
                      printf format, "'`gettext "Code"`'", " '`gettext "Language"`'", " '`gettext "Country"`'",\
4c79b5
                      " '`gettext "Status"`'", " '`gettext "LastRev"`'", " '`gettext "Author"`'"
4c79b5
                      printf "--------------------------------------------------------------------------------\n"}
4c79b5
                     {printf format, substr($1,0,7), substr($2,0,15), substr($3,0,15), $4, $5, $6}
4c79b5
                 END {printf "--------------------------------------------------------------------------------\n"}'
4c79b5
}