|
Alain Reguera Delgado |
f23b0d |
#!/bin/bash
|
|
Alain Reguera Delgado |
f23b0d |
######################################################################
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# tcar - The CentOS Artwork Repository automation tool.
|
|
Alain Reguera Delgado |
c0ca71 |
# Copyright © 2014 The CentOS Artwork SIG
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# This program is free software; you can redistribute it and/or
|
|
Alain Reguera Delgado |
c0ca71 |
# modify it under the terms of the GNU General Public License as
|
|
Alain Reguera Delgado |
c0ca71 |
# published by the Free Software Foundation; either version 2 of the
|
|
Alain Reguera Delgado |
c0ca71 |
# License, or (at your option) any later version.
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# This program is distributed in the hope that it will be useful,
|
|
Alain Reguera Delgado |
c0ca71 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
c0ca71 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
c0ca71 |
# General Public License for more details.
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
c0ca71 |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
c0ca71 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# Alain Reguera Delgado <al@centos.org.cu>
|
|
Alain Reguera Delgado |
c0ca71 |
# 39 Street No. 4426 Cienfuegos, Cuba.
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
######################################################################
|
|
Alain Reguera Delgado |
c0ca71 |
|
|
Alain Reguera Delgado |
c0ca71 |
# Standardize localization tasks. The locale command provides three
|
|
Alain Reguera Delgado |
c0ca71 |
# ways of producing localization files:
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# 1. Produce localization for one file only (when a regular file is
|
|
Alain Reguera Delgado |
c0ca71 |
# provided as argument in the command-line),
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# 2. Produce localization files for all files in the current
|
|
Alain Reguera Delgado |
c0ca71 |
# directory you provided in the command-line (when a directory is
|
|
Alain Reguera Delgado |
c0ca71 |
# provided as argument), and
|
|
Alain Reguera Delgado |
f23b0d |
#
|
|
Alain Reguera Delgado |
c0ca71 |
# 3. Produce localization files for all files in the current
|
|
Alain Reguera Delgado |
c0ca71 |
# directory recursively (when a directory is provided as argument in
|
|
Alain Reguera Delgado |
c0ca71 |
# the command-line and the --recursive option is also provided).
|
|
Alain Reguera Delgado |
f23b0d |
function locale {
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
99668a |
tcar_checkWorkplace
|
|
Alain Reguera Delgado |
99668a |
|
|
Alain Reguera Delgado |
f23b0d |
# Define flags controlling they way locale module produce
|
|
Alain Reguera Delgado |
f23b0d |
# localization files.
|
|
Alain Reguera Delgado |
f23b0d |
local LOCALE_FLAG_RECURSIVE="false"
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Initialize module's actions.
|
|
Alain Reguera Delgado |
f23b0d |
local ACTIONS=''
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Redefine module's actions based on arguments passed through
|
|
Alain Reguera Delgado |
f23b0d |
# command-line.
|
|
Alain Reguera Delgado |
f23b0d |
locale_getOptions
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Verify the current locale information to avoid English messages
|
|
Alain Reguera Delgado |
f23b0d |
# from being localized to themselves. The English language is used
|
|
Alain Reguera Delgado |
f23b0d |
# as reference to write translatable strings inside the source
|
|
Alain Reguera Delgado |
f23b0d |
# files.
|
|
Alain Reguera Delgado |
f23b0d |
if [[ ${TCAR_SCRIPT_LANG_LC} =~ '^C$' ]];then
|
|
Alain Reguera Delgado |
f23b0d |
tcar_printMessage "`gettext "The C locale cannot be localized to itself."`" --as-error-line
|
|
Alain Reguera Delgado |
f23b0d |
fi
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Process arguments passed to locale module, based on whether they
|
|
Alain Reguera Delgado |
f23b0d |
# are files or directories.
|
|
Alain Reguera Delgado |
f23b0d |
for ARGUMENT in ${TCAR_MODULE_ARGUMENT};do
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
0349b6 |
local ARGUMENT=$(tcar_printPath "${ARGUMENT}")
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
if [[ -f ${ARGUMENT} ]];then
|
|
Alain Reguera Delgado |
f23b0d |
tcar_setModuleEnvironment -m "files" -t "child" -g "${ARGUMENT}"
|
|
Alain Reguera Delgado |
f23b0d |
elif [[ -d ${ARGUMENT} ]];then
|
|
Alain Reguera Delgado |
f23b0d |
tcar_setModuleEnvironment -m "directories" -t "child" -g "${ARGUMENT}"
|
|
Alain Reguera Delgado |
f23b0d |
else
|
|
Alain Reguera Delgado |
f23b0d |
tcar_printMessage "`gettext "The argument provided isn't valid."`" --as-error-line
|
|
Alain Reguera Delgado |
f23b0d |
fi
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
done
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
}
|