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