|
Alain Reguera Delgado |
2e37b0 |
#!/bin/bash
|
|
Alain Reguera Delgado |
2e37b0 |
######################################################################
|
|
Alain Reguera Delgado |
2e37b0 |
#
|
|
Alain Reguera Delgado |
54b96d |
# render_setLocalizedXml.sh -- This function standardizes the way
|
|
Alain Reguera Delgado |
54b96d |
# (.po) translation files are applied to XML files (e.g., .docbook,
|
|
Alain Reguera Delgado |
54b96d |
# .svg) in order to produce their related translated instances, used
|
|
Alain Reguera Delgado |
54b96d |
# to expand translation markers and produce the final file format in
|
|
Alain Reguera Delgado |
54b96d |
# different languages. Assuming no translation file exists, an
|
|
Alain Reguera Delgado |
54b96d |
# untranslated instance is taken from the design model and created
|
|
Alain Reguera Delgado |
54b96d |
# (i.e., just a copy) from it. Using a design model instance
|
|
Alain Reguera Delgado |
54b96d |
# (translated or not) is required in order to expand translation
|
|
Alain Reguera Delgado |
54b96d |
# markers safely.
|
|
Alain Reguera Delgado |
2e37b0 |
#
|
|
Alain Reguera Delgado |
2e37b0 |
# Written by:
|
|
Alain Reguera Delgado |
2e37b0 |
# * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
|
|
Alain Reguera Delgado |
2e37b0 |
#
|
|
Alain Reguera Delgado |
809ecc |
# Copyright (C) 2009-2013 The CentOS Artwork SIG
|
|
Alain Reguera Delgado |
2e37b0 |
#
|
|
Alain Reguera Delgado |
2e37b0 |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
2e37b0 |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
809ecc |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
809ecc |
# your option) any later version.
|
|
Alain Reguera Delgado |
2e37b0 |
#
|
|
Alain Reguera Delgado |
2e37b0 |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
2e37b0 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
2e37b0 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
2e37b0 |
# General Public License for more details.
|
|
Alain Reguera Delgado |
2e37b0 |
#
|
|
Alain Reguera Delgado |
2e37b0 |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
2e37b0 |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
2e37b0 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
2e37b0 |
#
|
|
Alain Reguera Delgado |
2e37b0 |
######################################################################
|
|
Alain Reguera Delgado |
2e37b0 |
|
|
Alain Reguera Delgado |
2e37b0 |
function render_setLocalizedXml {
|
|
Alain Reguera Delgado |
2e37b0 |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Define absolute path to source instance.
|
|
Alain Reguera Delgado |
2cf5c6 |
local SOURCE="${1}"
|
|
Alain Reguera Delgado |
2cf5c6 |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Define absolute path to target instance.
|
|
Alain Reguera Delgado |
2cf5c6 |
local TARGET="${2}"
|
|
Alain Reguera Delgado |
2cf5c6 |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Verify source instance and the no-locale flag. When source
|
|
Alain Reguera Delgado |
2cf5c6 |
# instance already exists, don't create a new file for it.
|
|
Alain Reguera Delgado |
2cf5c6 |
# Instead, link it using a symbolic link.
|
|
Alain Reguera Delgado |
2cf5c6 |
if [[ -f ${SOURCE} ]];then
|
|
Alain Reguera Delgado |
2cf5c6 |
tcar_checkFiles -i 'text/xml' ${SOURCE}
|
|
Alain Reguera Delgado |
2cf5c6 |
if [[ ${SOURCE} =~ "^${TCAR_SCRIPT_TEMPDIR}" ]];then
|
|
Alain Reguera Delgado |
2cf5c6 |
/bin/ln -s ${SOURCE} ${TARGET}
|
|
Alain Reguera Delgado |
2cf5c6 |
return
|
|
Alain Reguera Delgado |
2cf5c6 |
elif [[ ${RENDER_FLAG_NO_LOCALE} == 'true' ]];then
|
|
Alain Reguera Delgado |
2cf5c6 |
tcar_printFile ${SOURCE} > ${TARGET}
|
|
Alain Reguera Delgado |
2cf5c6 |
tcar_checkFiles -i 'text/xml' ${TARGET}
|
|
Alain Reguera Delgado |
2cf5c6 |
return
|
|
Alain Reguera Delgado |
2cf5c6 |
fi
|
|
Alain Reguera Delgado |
2cf5c6 |
fi
|
|
Alain Reguera Delgado |
54b96d |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Verify existence of translation files.
|
|
Alain Reguera Delgado |
2cf5c6 |
tcar_checkFiles -efi 'text/x-po' ${TRANSLATIONS[*]}
|
|
Alain Reguera Delgado |
54b96d |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Define absolute path to translation instance.
|
|
Alain Reguera Delgado |
2cf5c6 |
local TRANSLATION=$(tcar_getTemporalFile "messages.po")
|
|
Alain Reguera Delgado |
54b96d |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Combine available translations file into one translation
|
|
Alain Reguera Delgado |
2cf5c6 |
# instance.
|
|
Alain Reguera Delgado |
2cf5c6 |
msgcat -u -o ${TRANSLATION} ${TRANSLATIONS[*]}
|
|
Alain Reguera Delgado |
2e37b0 |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Verify existence of final location. In case it doesn't exist,
|
|
Alain Reguera Delgado |
2cf5c6 |
# create it.
|
|
Alain Reguera Delgado |
2cf5c6 |
if [[ $(dirname ${RENDER_TARGET}) ]];then
|
|
Alain Reguera Delgado |
2cf5c6 |
mkdir -p $(dirname ${RENDER_TARGET})
|
|
Alain Reguera Delgado |
2cf5c6 |
fi
|
|
Alain Reguera Delgado |
06b3a0 |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Move to final location before processing source file in order
|
|
Alain Reguera Delgado |
2cf5c6 |
# for relative calls (e.g., image files) inside the source files
|
|
Alain Reguera Delgado |
2cf5c6 |
# can be found by xml2po and no warning be printed from it.
|
|
Alain Reguera Delgado |
2cf5c6 |
pushd $(dirname ${RENDER_TARGET}) > /dev/null
|
|
Alain Reguera Delgado |
54b96d |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Create the localized instance from design model.
|
|
Alain Reguera Delgado |
2cf5c6 |
tcar_printFile ${SOURCE} | xml2po -a -l ${TCAR_SCRIPT_LANG_LC} \
|
|
Alain Reguera Delgado |
2cf5c6 |
-p ${TRANSLATION} -o ${TARGET} -
|
|
Alain Reguera Delgado |
2b2258 |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Remove .xml2po.mo temporal file.
|
|
Alain Reguera Delgado |
2cf5c6 |
if [[ -f ./.xml2po.mo ]];then
|
|
Alain Reguera Delgado |
2cf5c6 |
rm ./.xml2po.mo
|
|
Alain Reguera Delgado |
2cf5c6 |
fi
|
|
Alain Reguera Delgado |
54b96d |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Return to previous location.
|
|
Alain Reguera Delgado |
2cf5c6 |
popd > /dev/null
|
|
Alain Reguera Delgado |
2b2258 |
|
|
Alain Reguera Delgado |
2cf5c6 |
# Remove instance created to store template translations.
|
|
Alain Reguera Delgado |
2cf5c6 |
if [[ -f ${TRANSLATION} ]];then
|
|
Alain Reguera Delgado |
2cf5c6 |
rm ${TRANSLATION}
|
|
Alain Reguera Delgado |
2e37b0 |
fi
|
|
Alain Reguera Delgado |
2e37b0 |
|
|
Alain Reguera Delgado |
2e37b0 |
}
|