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

4e4b4d
#!/bin/bash
4e4b4d
#
4e4b4d
# locale_updateMessages.sh -- This function updates translatable
4e4b4d
# strings inside portable object templates (.pot) and creates portable
4e4b4d
# objects (.po) from it. Translatable strings are taken from both
4e4b4d
# XML-based  files (using xml2po) and shell scripts (using xgettext).
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
# $Id$
4e4b4d
# ----------------------------------------------------------------------
4e4b4d
4e4b4d
function locale_updateMessages {
4e4b4d
4e4b4d
    local ACTIONNAM=''
4e4b4d
4e4b4d
    # Define base directory structure where locale files (.pot, .po,
4e4b4d
    # .mo) are stored using parallel directories layout.
4e4b4d
    local ACTIONDIR="$(cli_getRepoTLDir)/Locales"
4e4b4d
4e4b4d
    # Syncronize changes between the working copy and the central
4e4b4d
    # repository.
0d4faa
    cli_commitRepoChanges
4e4b4d
4e4b4d
    # Evaluate action value to determine whether to use xml2po to
4e4b4d
    # extract translatable strings from XML-based files or to use
4e4b4d
    # xgettext to extract translatable strings from shell script
4e4b4d
    # files.
4e4b4d
    if [[ $ACTIONVAL =~ "^${ACTIONDIR}/(Identity|Manuals)/.+$" ]];then
0d4faa
4e4b4d
        # Update translatable strings inside portable object templates
4e4b4d
        # for XML-based files (e.g., scalable vector graphics).
4e4b4d
        ACTIONNAM="${FUNCNAM}_updateMessageXml" 
0d4faa
4e4b4d
    elif [[ $ACTIONVAL =~ "^${ACTIONDIR}/Scripts/.+$" ]];then
0d4faa
4e4b4d
        # Update translatable strings inside portable object templates
4e4b4d
        # for shell scripts (e.g., centos-art.sh script).
4e4b4d
        ACTIONNAM="${FUNCNAM}_updateMessageShell"
0d4faa
4e4b4d
    else
0d4faa
4e4b4d
        cli_printMessage "`gettext "The path provided can't be processed."`" 'AsErrorLine'
4e4b4d
        cli_printMessage "$(caller)" 'AsToKnowMoreLine'
0d4faa
4e4b4d
    fi
4e4b4d
4e4b4d
    # Execute action name.
4e4b4d
    if [[ $ACTIONNAM != '' ]];then
4e4b4d
        eval $ACTIONNAM
4e4b4d
    fi
4e4b4d
4e4b4d
    # Syncronize changes between the working copy and the central
4e4b4d
    # repository.
0d4faa
    cli_commitRepoChanges
4e4b4d
4e4b4d
}