|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# locale.sh -- This function provides internationalization features
|
|
|
878a2b |
# for centos-art.sh script through GNU gettext standard processes.
|
|
|
878a2b |
#
|
|
|
03486a |
# Copyright (C) 2009, 2010, 2011, 2012 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 |
# Verify current locale information to avoid English messages from
|
|
|
878a2b |
# being localized to themselves. The English language is used as
|
|
|
878a2b |
# reference to write translatable strings inside the source files.
|
|
|
878a2b |
if [[ $(cli_getCurrentLocale) =~ '^en' ]];then
|
|
|
878a2b |
cli_printMessage "`gettext "The English language cannot be localized to itself."`" --as-error-line
|
|
|
878a2b |
fi
|
|
|
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
|
|
|
878a2b |
# components they represent under the `trunk/Identity',
|
|
|
878a2b |
# `trunk/Manuals' or `trunk/Scripts' directory structures. The
|
|
|
878a2b |
# localization base directory must be used as source location for
|
|
|
878a2b |
# subversion operations (e.g., status, update, commit, etc.).
|
|
|
878a2b |
# Otherwise, it would be difficult to add directory structures
|
|
|
878a2b |
# that have several levels down from the localization base
|
|
|
878a2b |
# directory up to the repository (e.g., it is not possible in
|
|
|
878a2b |
# subversion to add a directory which parent directory hasn't been
|
|
|
878a2b |
# added to the repository previously.).
|
|
|
a1a636 |
L10N_BASEDIR="$(cli_getRepoTLDir)/Locales"
|
|
|
878a2b |
|
|
|
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 |
# Syncronize changes between repository and working copy. At this
|
|
|
878a2b |
# point, changes in the repository are merged in the working copy
|
|
|
878a2b |
# and changes in the working copy committed up to repository.
|
|
|
878a2b |
cli_syncroRepoChanges "${L10N_BASEDIR}"
|
|
|
878a2b |
|
|
|
878a2b |
# Loop through non-option arguments passed to centos-art.sh script
|
|
|
878a2b |
# through its command-line.
|
|
|
878a2b |
for ACTIONVAL in "$@";do
|
|
|
878a2b |
|
|
|
878a2b |
# Sanitate non-option argument to be sure it matches the
|
|
|
878a2b |
# directory convenctions stablished by centos-art.sh script
|
|
|
878a2b |
# against source locations in the working copy.
|
|
|
878a2b |
ACTIONVAL=$(cli_checkRepoDirSource "${ACTIONVAL}")
|
|
|
878a2b |
|
|
|
878a2b |
# Verify directory passed as non-option argument to be sure it
|
|
|
878a2b |
# supports localization.
|
|
|
878a2b |
if [[ ! $(cli_isLocalized "${ACTIONVAL}") == 'true' ]];then
|
|
|
878a2b |
cli_printMessage "`gettext "The path provided does not support localization."`" --as-error-line
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
878a2b |
# Define localization working directory using directory passed
|
|
|
878a2b |
# as non-option argument. The localization working directory
|
|
|
878a2b |
# is the place where POT and PO files are stored inside the
|
|
|
878a2b |
# working copy.
|
|
|
878a2b |
L10N_WORKDIR=$(echo "${ACTIONVAL}" \
|
|
|
a1a636 |
| sed -r -e "s!trunk/(Identity|Scripts|Manuals)!trunk/Locales/\1!")/$(cli_getCurrentLocale)
|
|
|
878a2b |
|
|
|
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 |
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
# Syncronize changes between repository and working copy. At this
|
|
|
878a2b |
# point, changes in the repository are merged in the working copy
|
|
|
878a2b |
# and changes in the working copy committed up to repository.
|
|
|
878a2b |
cli_syncroRepoChanges "${L10N_BASEDIR}"
|
|
|
878a2b |
|
|
|
878a2b |
}
|