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

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# locale_doMessages.sh -- This function standardize centos-art.sh
4c79b5
# localization process using gettext commands.  All messages inside
4c79b5
# centos-art.sh script are written in English language.
4c79b5
#
72c8a5
# Copyright (C) 2009-2011  Alain Reguera Delgado
4c79b5
# 
7cd8e9
# This program is free software; you can redistribute it and/or
7cd8e9
# modify it under the terms of the GNU General Public License as
7cd8e9
# published by the Free Software Foundation; either version 2 of the
7cd8e9
# License, or (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_doMessages {
4c79b5
4c79b5
    # Define variables as local to avoid conflicts outside.
4c79b5
    local POT_FILE=$TEXTDOMAINDIR/$TEXTDOMAIN.pot
4c79b5
    local PO_FILE=$TEXTDOMAINDIR/$(cli_getCurrentLocale)/$TEXTDOMAIN.po
4c79b5
    local MO_FILE=$TEXTDOMAINDIR/$(cli_getCurrentLocale)/LC_MESSAGES/$TEXTDOMAIN.mo
4c79b5
    local LANGNAME=$(cli_getLangName $(cli_getCurrentLocale))
4c79b5
    local PO_HEAD_DATE=''
4c79b5
    local PO_HEAD_BUGS=''
4c79b5
4c79b5
    # Output action message.
4c79b5
    cli_printMessage "`gettext "The following translation files will be updated:"`"
4c79b5
    cli_printMessage "$POT_FILE" "AsResponseLine"
4c79b5
    cli_printMessage "$PO_FILE" "AsResponseLine"
4c79b5
    cli_printMessage "$MO_FILE" "AsResponseLine"
4c79b5
    cli_printMessage "`gettext "Do you want to continue?"`" "AsYesOrNoRequestLine"
4c79b5
4c79b5
    # Prepare directory structure for centos-art.sh localization
4c79b5
    # files.
4c79b5
    if [[ ! -d $(dirname $MO_FILE) ]];then
4c79b5
        mkdir -p $(dirname $MO_FILE)
4c79b5
    fi
4c79b5
4c79b5
    # Create portable object template (.pot). 
4c79b5
    find /home/centos/artwork/trunk/Scripts/Bash -name '*.sh' \
4c79b5
        | xargs xgettext --language=Shell --output=$POT_FILE -
4c79b5
4c79b5
    # Create portable object (.po) for the current language.
4c79b5
    if [[ ! -f $PO_FILE ]];then
4c79b5
        msginit --input=$POT_FILE --output=$PO_FILE
4c79b5
    else
4c79b5
        msgmerge --update $PO_FILE $POT_FILE
4c79b5
    fi
4c79b5
4c79b5
    # Update portable object bugs report in its header entries. This
4c79b5
    # entry is removed each time the portable object is generated. To
4c79b5
    # avoid loosing its value, re-define it before editing the portable
4c79b5
    # object (.po) file.
4c79b5
    PO_HEAD_BUGS="\"Report-Msgid-Bugs-To: CentOS Documentation SIG <centos-docs@centos.org>\\\n\""
4c79b5
    sed -i -r "/^\"Report-Msgid-Bugs-To:/c$PO_HEAD_BUGS" $PO_FILE
4c79b5
4c79b5
    # Edit portable object (.po) for the current language. In this
4c79b5
    # step is when translators do their work.
4c79b5
    eval $EDITOR $PO_FILE
4c79b5
4c79b5
    # Update portable object revision date in its header entries.
4c79b5
    PO_HEAD_DATE="\"PO-Revision-Date: $(date "+%Y-%m-%d %H:%M%z")\\\n\""
4c79b5
    sed -i -r "/^\"PO-Revision-Date:/c$PO_HEAD_DATE" $PO_FILE
4c79b5
4c79b5
    # Create machine object (.mo).
4c79b5
    msgfmt $PO_FILE --output=$MO_FILE
4c79b5
3f3263
    # Check repository changes and ask you to commit them up to
3f3263
    # central repository.
3f3263
    cli_commitRepoChanges "$TEXTDOMAINDIR"
3f3263
    
4c79b5
}