|
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 |
f23b0d |
######################################################################
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
c0ca71 |
# Retrieve translatable strings from shell scripts files. Normally,
|
|
Alain Reguera Delgado |
c0ca71 |
# this function takes the file provided as argument in the
|
|
Alain Reguera Delgado |
c0ca71 |
# command-line and creates a list of all files that share the same
|
|
Alain Reguera Delgado |
c0ca71 |
# file extension in the same directory structure and retrieve
|
|
Alain Reguera Delgado |
c0ca71 |
# translation messages from it. Translation messages are stored in a
|
|
Alain Reguera Delgado |
c0ca71 |
# PO file for each supported language under the Locales directory. In
|
|
Alain Reguera Delgado |
c0ca71 |
# case the --recursive option is also provided, the list of files to
|
|
Alain Reguera Delgado |
c0ca71 |
# process is build recursively.
|
|
Alain Reguera Delgado |
f23b0d |
function sh {
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Verify existence and type of file being processed.
|
|
Alain Reguera Delgado |
f23b0d |
tcar_checkFiles -efi 'application/x-shellscript' "${RENDER_FROM}"
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
local FILES=''
|
|
Alain Reguera Delgado |
f23b0d |
local DIRECTORY=$(dirname ${RENDER_FROM})
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Build list of all script files that xgettext will look for
|
|
Alain Reguera Delgado |
f23b0d |
# translatable strings inside. By default only scripts in the
|
|
Alain Reguera Delgado |
f23b0d |
# current directory will be looked out.
|
|
Alain Reguera Delgado |
f23b0d |
if [[ ${LOCALE_FLAG_RECURSIVE} == 'true' ]];then
|
|
Alain Reguera Delgado |
dd8f6b |
FILES=$(tcar_getFilesList -t 'f' -p '.+\.sh$' "${DIRECTORY}")
|
|
Alain Reguera Delgado |
f23b0d |
else
|
|
Alain Reguera Delgado |
dd8f6b |
FILES=$(tcar_getFilesList -i '1' -a '1' -t 'f' -p '.+\.sh$' "${DIRECTORY}")
|
|
Alain Reguera Delgado |
f23b0d |
fi
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Verify found files existence and type before processing them.
|
|
Alain Reguera Delgado |
f23b0d |
tcar_checkFiles -efi 'application/x-shellscript' "${FILES}"
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Retrieve translatable strings from shell script files and create
|
|
Alain Reguera Delgado |
f23b0d |
# the portable object template (.pot) from them.
|
|
Alain Reguera Delgado |
f23b0d |
xgettext --output=${POT_FILE} --width=70 \
|
|
Alain Reguera Delgado |
f23b0d |
--package-name=${PACKAGE_NAME} \
|
|
Alain Reguera Delgado |
f23b0d |
--package-version=${PACKAGE_VERSION} \
|
|
Alain Reguera Delgado |
f23b0d |
--msgid-bugs-address="centos-l10n-${TCAR_SCRIPT_LANG_LL}@centos.org.cu" \
|
|
Alain Reguera Delgado |
f23b0d |
--sort-by-file ${FILES}
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# When there is not any translatable string to retrieve from file,
|
|
Alain Reguera Delgado |
f23b0d |
# the POT file is not created. Be aware of this when retrieving
|
|
Alain Reguera Delgado |
f23b0d |
# translatable strings from several files (e.g., you are
|
|
Alain Reguera Delgado |
f23b0d |
# processing a directory full of svgz files, but some of them have
|
|
Alain Reguera Delgado |
f23b0d |
# no translatable string inside).
|
|
Alain Reguera Delgado |
f23b0d |
if [[ ! -f ${POT_FILE} ]];then
|
|
Alain Reguera Delgado |
f23b0d |
return
|
|
Alain Reguera Delgado |
f23b0d |
fi
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# Verify, initialize or update portable objects from portable
|
|
Alain Reguera Delgado |
f23b0d |
# object templates.
|
|
Alain Reguera Delgado |
f23b0d |
update_convertPotToPo "${POT_FILE}" "${PO_FILE}"
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
# At this point some changes might be realized inside the PO file,
|
|
Alain Reguera Delgado |
f23b0d |
# so we need to update the related MO file based on recently
|
|
Alain Reguera Delgado |
f23b0d |
# updated PO files here in order for `centos-art.sh' script to
|
|
Alain Reguera Delgado |
f23b0d |
# print out the most up to date revision of localized messages.
|
|
Alain Reguera Delgado |
f23b0d |
# Notice that this is required only if we were localizing shell
|
|
Alain Reguera Delgado |
f23b0d |
# scripts because xml-based files don't need the MO files.
|
|
Alain Reguera Delgado |
f23b0d |
update_convertPoToMo
|
|
Alain Reguera Delgado |
f23b0d |
|
|
Alain Reguera Delgado |
f23b0d |
}
|