|
|
4c79b5 |
#!/bin/bash
|
|
|
4c79b5 |
#
|
|
|
957ef9 |
# locale.sh -- This function provides internationalization features
|
|
|
957ef9 |
# for centos-art.sh script through gettext standard processes.
|
|
|
4c79b5 |
#
|
|
|
2d3646 |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# 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
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
418249 |
# $Id$
|
|
|
4c79b5 |
# ----------------------------------------------------------------------
|
|
|
4c79b5 |
|
|
|
4c79b5 |
function locale {
|
|
|
4c79b5 |
|
|
|
f1a655 |
# Do not locale messages for English language. The English
|
|
|
f1a655 |
# language is already used as translation pattern and there is no
|
|
|
f1a655 |
# translation messages for it.
|
|
|
f1a655 |
if [[ $(cli_getCurrentLocale) =~ '^en' ]];then
|
|
|
510fad |
cli_printMessage "`gettext "Cannot locale English language to itself."`" --as-error-line
|
|
|
f1a655 |
fi
|
|
|
f1a655 |
|
|
|
73abe0 |
local ACTIONNAM=''
|
|
|
73abe0 |
local ACTIONVAL=''
|
|
|
73abe0 |
|
|
|
2b3016 |
# Initialize default value to create/update machine object flag.
|
|
|
bf6bff |
# The machine object flag (--dont-create-mo) controls whether
|
|
|
bf6bff |
# centos-art.sh script does create/update the machine object
|
|
|
bf6bff |
# related object or not.
|
|
|
0d4faa |
local FLAG_DONT_CREATE_MO='false'
|
|
|
2b3016 |
|
|
|
73abe0 |
# Interpret arguments and options passed through command-line.
|
|
|
9fe4a2 |
locale_getOptions
|
|
|
73abe0 |
|
|
|
73abe0 |
# Redefine positional parameters using ARGUMENTS. At this point,
|
|
|
73abe0 |
# option arguments have been removed from ARGUMENTS variable and
|
|
|
73abe0 |
# only non-option arguments remain in it.
|
|
|
73abe0 |
eval set -- "$ARGUMENTS"
|
|
|
73abe0 |
|
|
|
73abe0 |
# Define action name. It does matter what option be passed to
|
|
|
73abe0 |
# centos-art, there are many different actions to perform based on
|
|
|
73abe0 |
# the option passed (e.g., `--edit', `--read', `--search', etc.).
|
|
|
73abe0 |
# In that sake, we defined action name inside document_getArguments,
|
|
|
73abe0 |
# at the moment of interpreting options.
|
|
|
73abe0 |
|
|
|
73abe0 |
# Define action value. As convenction, we use non-option arguments
|
|
|
73abe0 |
# to define the action value (ACTIONVAL) variable.
|
|
|
73abe0 |
for ACTIONVAL in "$@";do
|
|
|
73abe0 |
|
|
|
73abe0 |
# Check action value. Be sure the action value matches the
|
|
|
73abe0 |
# convenctions defined for source locations inside the working
|
|
|
73abe0 |
# copy.
|
|
|
73abe0 |
cli_checkRepoDirSource
|
|
|
73abe0 |
|
|
|
ed2bf0 |
# Define work directory. This is the place where locales
|
|
|
ed2bf0 |
# directories will be stored in.
|
|
|
ed2bf0 |
WORKDIR=$(echo ${ACTIONVAL} \
|
|
|
31b423 |
| sed -r -e "s!trunk/(Identity|Scripts)!trunk/Locales/\1!")
|
|
|
ed2bf0 |
|
|
|
ed2bf0 |
# Add current locale to work directory. This is the place
|
|
|
ed2bf0 |
# where parent directories specific translation messages
|
|
|
ed2bf0 |
# (e.g., the .po, .pot and .mo files) will be stored in. The
|
|
|
ed2bf0 |
# `locale' functionality creates translation messages for all
|
|
|
ed2bf0 |
# translatable files inside the parent directory and never for
|
|
|
ed2bf0 |
# individual files inside the same parent directory.
|
|
|
ed2bf0 |
WORKDIR=$WORKDIR/$(cli_getCurrentLocale)
|
|
|
ed2bf0 |
|
|
|
73abe0 |
# Syncronize changes between repository and working copy. At
|
|
|
73abe0 |
# this point, changes in the repository are merged in the
|
|
|
73abe0 |
# working copy and changes in the working copy committed up to
|
|
|
73abe0 |
# repository.
|
|
|
73abe0 |
cli_syncroRepoChanges "${WORKDIR}"
|
|
|
73abe0 |
|
|
|
73abe0 |
# Execute action name.
|
|
|
73abe0 |
if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then
|
|
|
73abe0 |
eval $ACTIONNAM
|
|
|
73abe0 |
else
|
|
|
510fad |
cli_printMessage "`gettext "A valid action is required."`" --as-error-line
|
|
|
73abe0 |
fi
|
|
|
73abe0 |
|
|
|
73abe0 |
# Commit changes from working copy to central repository only.
|
|
|
73abe0 |
# At this point, changes in the repository are not merged in
|
|
|
73abe0 |
# the working copy, but chages in the working copy do are
|
|
|
73abe0 |
# committed up to repository.
|
|
|
73abe0 |
cli_commitRepoChanges "${WORKDIR}"
|
|
|
73abe0 |
|
|
|
73abe0 |
done
|
|
|
4c79b5 |
|
|
|
4c79b5 |
}
|