|
|
d1d5a8 |
#!/bin/bash
|
|
|
d1d5a8 |
#
|
|
|
d1d5a8 |
# locale_updateMessageShell.sh -- This function parses shell scripts
|
|
|
d1d5a8 |
# under action value, retrives translatable strings and
|
|
|
d1d5a8 |
# creates/updates both portable object templates (.pot) and portable
|
|
|
bf6bff |
# objects (.po).
|
|
|
d1d5a8 |
#
|
|
|
d1d5a8 |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
d1d5a8 |
#
|
|
|
d1d5a8 |
# This program is free software; you can redistribute it and/or
|
|
|
d1d5a8 |
# modify it under the terms of the GNU General Public License as
|
|
|
d1d5a8 |
# published by the Free Software Foundation; either version 2 of the
|
|
|
d1d5a8 |
# License, or (at your option) any later version.
|
|
|
d1d5a8 |
#
|
|
|
d1d5a8 |
# This program is distributed in the hope that it will be useful, but
|
|
|
d1d5a8 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
d1d5a8 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
d1d5a8 |
# General Public License for more details.
|
|
|
d1d5a8 |
#
|
|
|
d1d5a8 |
# You should have received a copy of the GNU General Public License
|
|
|
d1d5a8 |
# along with this program; if not, write to the Free Software
|
|
|
d1d5a8 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
d1d5a8 |
# USA.
|
|
|
d1d5a8 |
#
|
|
|
d1d5a8 |
# ----------------------------------------------------------------------
|
|
|
d1d5a8 |
# $Id$
|
|
|
d1d5a8 |
# ----------------------------------------------------------------------
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
function locale_updateMessageShell {
|
|
|
d1d5a8 |
|
|
|
bf6bff |
# Redefine locales work directory to store locale-specific files.
|
|
|
bf6bff |
# The redefinition should be done locally to avoid undesired
|
|
|
bf6bff |
# concatenations.
|
|
|
bf6bff |
local WORKDIR=${WORKDIR}/$(cli_getCurrentLocale)
|
|
|
d1d5a8 |
|
|
|
bf6bff |
# Create locales work directory if it doesn't exist.
|
|
|
bf6bff |
if [[ ! -d ${WORKDIR} ]];then
|
|
|
bf6bff |
mkdir -p ${WORKDIR}
|
|
|
bf6bff |
fi
|
|
|
d1d5a8 |
|
|
|
bf6bff |
# Define file-name used as reference to create portable object
|
|
|
bf6bff |
# templates (.pot), portable objects (.po) and machine objects
|
|
|
bf6bff |
# (.mo).
|
|
|
bf6bff |
local FILE="${WORKDIR}/${TEXTDOMAIN}"
|
|
|
d1d5a8 |
|
|
|
bf6bff |
# Redefine filter pattern in order to get shell scripts only.
|
|
|
bf6bff |
# Since centos-art.sh is written in Bash, centos-art.sh does
|
|
|
bf6bff |
# retrive translatable strings from shell scripts written in Bash
|
|
|
bf6bff |
# only.
|
|
|
bf6bff |
if [[ $ACTIONVAL =~ "$(cli_getRepoTLDir)/Scripts/Bash/.*$" ]];then
|
|
|
bf6bff |
FLAG_FILTER="${FLAG_FILTER}.*\.sh"
|
|
|
bf6bff |
else
|
|
|
bf6bff |
cli_printMessage "`gettext "The path provided can't be processed."`"
|
|
|
bf6bff |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
d1d5a8 |
fi
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Build list of XML-base files which we want retrive translatable
|
|
|
d1d5a8 |
# strings from.
|
|
|
bf6bff |
cli_getFilesList
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Print out action preamble. Since the `--filter' option can be
|
|
|
d1d5a8 |
# supplied, it is useful to know which files we are getting
|
|
|
d1d5a8 |
# translatable strings from.
|
|
|
d1d5a8 |
cli_printActionPreamble "${FILES}" "doLocale" 'AsResponseLine'
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Print action message.
|
|
|
d1d5a8 |
cli_printMessage "${FILE}.pot" 'AsUpdatingLine'
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Retrive translatable strings from XML-based files and
|
|
|
d1d5a8 |
# create the portable object template (.pot) for them.
|
|
|
d1d5a8 |
/usr/bin/xgettext --output=${FILE}.pot \
|
|
|
d1d5a8 |
--copyright-holder="CentOS Documentation SIG" \
|
|
|
d1d5a8 |
--width=70 --sort-by-file ${FILES}
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Verify xgettext exit status.
|
|
|
d1d5a8 |
if [[ $? != 0 ]];then
|
|
|
d1d5a8 |
cli_printMessage "`eval_gettext "The .pot \\\`\\\$FILE' could not be created."`"
|
|
|
d1d5a8 |
cli_printMessage "$(caller)" 'AsToKnowMoreLine'
|
|
|
d1d5a8 |
fi
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
if [[ ! -f ${FILE}.po ]];then
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Create portable object using portable object template, at
|
|
|
d1d5a8 |
# the same time we use output to print the action message.
|
|
|
d1d5a8 |
# There is no --quiet option for msginit command that let to
|
|
|
d1d5a8 |
# separate both printing action message and creation command
|
|
|
d1d5a8 |
# apart one from another).
|
|
|
d1d5a8 |
cli_printMessage $(msginit -i ${FILE}.pot -o ${FILE}.po --width=70 \
|
|
|
d1d5a8 |
--no-translator 2>&1 | cut -d' ' -f2 | sed -r 's!\.$!!') 'AsCreatingLine'
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Sanitate portable object metadata.
|
|
|
d1d5a8 |
locale_updateMessageMetadata "${FILE}.po"
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
else
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Print action message.
|
|
|
d1d5a8 |
cli_printMessage "${FILE}.po" 'AsUpdatingLine'
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
# Update portable object merging both portable object and
|
|
|
d1d5a8 |
# portable object template.
|
|
|
d1d5a8 |
msgmerge --output="${FILE}.po" "${FILE}.po" "${FILE}.pot" --quiet
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
fi
|
|
|
d1d5a8 |
|
|
|
d1d5a8 |
}
|