|
Alain Reguera Delgado |
8f60cb |
#!/bin/bash
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# locale.sh -- This function provides internationalization features
|
|
Alain Reguera Delgado |
8f60cb |
# for centos-art.sh script through GNU gettext standard processes.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# Copyright (C) 2009-2013 The CentOS Project
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
8f60cb |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
8f60cb |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
8f60cb |
# your option) any later version.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
8f60cb |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
8f60cb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
8f60cb |
# General Public License for more details.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
8f60cb |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
8f60cb |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
# $Id$
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
function locale {
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
local ACTIONNAMS=''
|
|
Alain Reguera Delgado |
8f60cb |
local ACTIONNAM=''
|
|
Alain Reguera Delgado |
8f60cb |
local ACTIONVAL=''
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Initialize machine object flag (`--dont-create-mo'). This flag
|
|
Alain Reguera Delgado |
8f60cb |
# controls whether the centos-art.sh script does create/update
|
|
Alain Reguera Delgado |
8f60cb |
# machine object (MO) files from related portable object (PO)
|
|
Alain Reguera Delgado |
8f60cb |
# files or not. By default, MO files are created.
|
|
Alain Reguera Delgado |
8f60cb |
local FLAG_DONT_CREATE_MO='false'
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define localization (l10n) base directory. This is the place
|
|
Alain Reguera Delgado |
8f60cb |
# where all translation messages are organized in. Translation
|
|
Alain Reguera Delgado |
8f60cb |
# messages are organized herein using the same layout of the
|
|
Alain Reguera Delgado |
8f60cb |
# components they represent under the `Identity',
|
|
Alain Reguera Delgado |
8f60cb |
# `Documentation/Manuals' or `Scripts' directory structures. The
|
|
Alain Reguera Delgado |
8f60cb |
# localization base directory must be used as source location for
|
|
Alain Reguera Delgado |
8f60cb |
# control version system operations (e.g., status, update, commit,
|
|
Alain Reguera Delgado |
8f60cb |
# etc.). Otherwise, it would be difficult to add directory
|
|
Alain Reguera Delgado |
8f60cb |
# structures that have several levels down from the localization
|
|
Alain Reguera Delgado |
8f60cb |
# base directory up to the repository (e.g.,
|
|
Alain Reguera Delgado |
8f60cb |
# subversion-1.4.2-4.el5_3.1.i386.rpm doesn't support recursive
|
|
Alain Reguera Delgado |
8f60cb |
# creation of directories which parent directories doesn't
|
|
Alain Reguera Delgado |
8f60cb |
# exist.).
|
|
Alain Reguera Delgado |
8f60cb |
local L10N_BASEDIR="${TCAR_WORKDIR}/Locales"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify current locale information to avoid English messages from
|
|
Alain Reguera Delgado |
8f60cb |
# being localized to themselves. The English language is used as
|
|
Alain Reguera Delgado |
8f60cb |
# reference to write translatable strings inside the source files.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ ${CLI_LANG_LC} =~ '^en' ]];then
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "`gettext "The English language cannot be localized to itself."`" --as-error-line
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Interpret arguments and options passed through command-line.
|
|
Alain Reguera Delgado |
8f60cb |
locale_getOptions
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Redefine positional parameters using ARGUMENTS. At this point,
|
|
Alain Reguera Delgado |
8f60cb |
# option arguments have been removed from ARGUMENTS variable and
|
|
Alain Reguera Delgado |
8f60cb |
# only non-option arguments remain in it.
|
|
Alain Reguera Delgado |
8f60cb |
eval set -- "${ARGUMENTS}"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Loop through non-option arguments passed to centos-art.sh script
|
|
Alain Reguera Delgado |
8f60cb |
# through its command-line.
|
|
Alain Reguera Delgado |
8f60cb |
for ACTIONVAL in "$@";do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Don't call locale_isLocalizable function here. Remember that
|
|
Alain Reguera Delgado |
8f60cb |
# this function (i.e., locale) is called from other functions
|
|
Alain Reguera Delgado |
8f60cb |
# using the cli_runFnEnvironment function to determine whether
|
|
Alain Reguera Delgado |
8f60cb |
# a location can accept or not localized messages. If you put
|
|
Alain Reguera Delgado |
8f60cb |
# the locale_isLocalizable function here, you would be
|
|
Alain Reguera Delgado |
8f60cb |
# duplicating its execution.
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Sanitate non-option arguments to be sure they match the
|
|
Alain Reguera Delgado |
8f60cb |
# directory conventions established by centos-art.sh script
|
|
Alain Reguera Delgado |
8f60cb |
# against source directory locations in the working copy.
|
|
Alain Reguera Delgado |
8f60cb |
ACTIONVAL=$(cli_checkRepoDirSource ${ACTIONVAL})
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify non-option arguments passed to centos-art.sh
|
|
Alain Reguera Delgado |
8f60cb |
# command-line. It should point to an existent directory under
|
|
Alain Reguera Delgado |
8f60cb |
# version control inside the working copy. Otherwise, if it
|
|
Alain Reguera Delgado |
8f60cb |
# doesn't point to a directory under version control, finish
|
|
Alain Reguera Delgado |
8f60cb |
# the script execution with an error message.
|
|
Alain Reguera Delgado |
8f60cb |
cli_checkFiles ${ACTIONVAL} -d --is-versioned
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Execute localization actions provided to centos-art.sh
|
|
Alain Reguera Delgado |
8f60cb |
# script through its command-line. Notice that localization
|
|
Alain Reguera Delgado |
8f60cb |
# actions will be executed in the same order they were
|
|
Alain Reguera Delgado |
8f60cb |
# provided in the command-line.
|
|
Alain Reguera Delgado |
8f60cb |
for ACTIONNAM in ${ACTIONNAMS};do
|
|
Alain Reguera Delgado |
8f60cb |
${ACTIONNAM}
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
}
|