|
|
ce40cb |
#!/bin/bash
|
|
|
ce40cb |
#
|
|
|
79e54d |
# cli_replaceTMarkers.sh -- This function standardizes
|
|
|
ce40cb |
# replacements for common translation markers. Raplacements are
|
|
|
ce40cb |
# applied to temporal instances used to produce the final file.
|
|
|
ce40cb |
#
|
|
|
3b0984 |
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
|
|
|
fa95b1 |
#
|
|
|
fa95b1 |
# This program is free software; you can redistribute it and/or modify
|
|
|
fa95b1 |
# it under the terms of the GNU General Public License as published by
|
|
|
dcd347 |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
dcd347 |
# your option) any later version.
|
|
|
fa95b1 |
#
|
|
|
74a058 |
# This program is distributed in the hope that it will be useful, but
|
|
|
74a058 |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
ce40cb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
ce40cb |
# General Public License for more details.
|
|
|
ce40cb |
#
|
|
|
ce40cb |
# You should have received a copy of the GNU General Public License
|
|
|
ce40cb |
# along with this program; if not, write to the Free Software
|
|
|
dcd347 |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
7ac5a5 |
#
|
|
|
ce40cb |
# ----------------------------------------------------------------------
|
|
|
ce40cb |
# $Id$
|
|
|
ce40cb |
# ----------------------------------------------------------------------
|
|
|
ce40cb |
|
|
|
79e54d |
function cli_replaceTMarkers {
|
|
|
ce40cb |
|
|
|
ce40cb |
# Initialize variables.
|
|
|
ce40cb |
local -a SRC
|
|
|
ce40cb |
local -a DST
|
|
|
ce40cb |
local COUNT=0
|
|
|
9b4d7d |
local COUNTSRC=0
|
|
|
9b4d7d |
local COUNTDST=0
|
|
|
28f865 |
local LOCATION=''
|
|
|
28f865 |
|
|
|
35950d |
# Define source location on which sed replacements take place.
|
|
|
35950d |
LOCATION="$1"
|
|
|
28f865 |
|
|
|
35950d |
# Verify file source location.
|
|
|
c9c5f7 |
cli_checkFiles $LOCATION
|
|
|
ce40cb |
|
|
|
b6f39b |
# Define copyright translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LAST='
|
|
|
7189c5 |
DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR='
|
|
|
7189c5 |
DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year)"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=COPYRIGHT_YEAR_LIST='
|
|
|
7189c5 |
DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-year-list)"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=COPYRIGHT_HOLDER='
|
|
|
7189c5 |
DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --copyright-holder)"
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define license translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=LICENSE='
|
|
|
7189c5 |
DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license)"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=LICENSE_URL='
|
|
|
7189c5 |
DST[((++${#DST[*]}))]="$(cli_printCopyrightInfo --license-url)"
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define theme translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=THEME='
|
|
|
b46b2c |
DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif)"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=THEMENAME='
|
|
|
b46b2c |
DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-name)"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=THEMERELEASE='
|
|
|
b46b2c |
DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-release)"
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define release-specific translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=RELEASE='
|
|
|
40acf2 |
DST[((++${#DST[*]}))]="$FLAG_RELEASEVER"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE='
|
|
|
40acf2 |
DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f1)"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=MINOR_RELEASE='
|
|
|
40acf2 |
DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f2)"
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define architectures translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=ARCH='
|
|
|
6d7e63 |
DST[((++${#DST[*]}))]="$(cli_getPathComponent $FLAG_BASEARCH --architecture)"
|
|
|
60f132 |
|
|
|
b6f39b |
# Define url translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=URL='
|
|
|
60f132 |
DST[((++${#DST[*]}))]=$(cli_printUrl '--home' '--with-locale')
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=URL_WIKI='
|
|
|
60f132 |
DST[((++${#DST[*]}))]=$(cli_printUrl '--wiki' '--with-locale')
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=URL_LISTS='
|
|
|
60f132 |
DST[((++${#DST[*]}))]=$(cli_printUrl '--lists' '--with-locale')
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=URL_FORUMS='
|
|
|
60f132 |
DST[((++${#DST[*]}))]=$(cli_printUrl '--forums' '--with-locale')
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=URL_MIRRORS='
|
|
|
60f132 |
DST[((++${#DST[*]}))]=$(cli_printUrl '--mirrors' '--with-locale')
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=URL_DOCS='
|
|
|
60f132 |
DST[((++${#DST[*]}))]=$(cli_printUrl '--docs' '--with-locale')
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=URL_IRC='
|
|
|
60f132 |
DST[((++${#DST[*]}))]=$(cli_printUrl '--irc')
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define emails translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=MAIL_DOCS='
|
|
|
b6f39b |
DST[((++${#DST[*]}))]="centos-docs@centos.org"
|
|
|
b6f39b |
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define locale translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=LOCALE_LL='
|
|
|
b6f39b |
DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')"
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=LOCALE='
|
|
|
b6f39b |
DST[((++${#DST[*]}))]="$(cli_getCurrentLocale)"
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define domain translation markers for domains.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=DOMAIN_LL='
|
|
|
f4f773 |
if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then
|
|
|
b6f39b |
DST[((++${#DST[*]}))]="$(cli_getCurrentLocale '--langcode-only')."
|
|
|
f4f773 |
else
|
|
|
b6f39b |
DST[((++${#DST[*]}))]=""
|
|
|
f4f773 |
fi
|
|
|
b6f39b |
|
|
|
b6f39b |
# Define repository translation markers.
|
|
|
b6f39b |
SRC[((++${#SRC[*]}))]='=REPO_TLDIR='
|
|
|
b6f39b |
DST[((++${#DST[*]}))]="$(cli_getRepoTLDir)"
|
|
|
03e97f |
SRC[((++${#SRC[*]}))]='=REPO_HOME='
|
|
|
03e97f |
DST[((++${#DST[*]}))]="${HOME}/artwork"
|
|
|
9b4d7d |
|
|
|
9b4d7d |
# Do replacement of nested translation markers.
|
|
|
9b4d7d |
while [[ $COUNTDST -lt ${#DST[@]} ]];do
|
|
|
9b4d7d |
|
|
|
9b4d7d |
# Verify existence of translation markers. If there is no
|
|
|
9b4d7d |
# translation marker on replacement, continue with the next
|
|
|
9b4d7d |
# one in the list.
|
|
|
9b4d7d |
if [[ ! ${DST[$COUNTDST]} =~ '=[A-Z_]+=' ]];then
|
|
|
9b4d7d |
# Increment destination counter.
|
|
|
9b4d7d |
COUNTDST=$(($COUNTDST + 1))
|
|
|
9b4d7d |
# The current replacement value doesn't have translation
|
|
|
9b4d7d |
# marker inside, so skip it and evaluate the next
|
|
|
9b4d7d |
# replacement value in the list.
|
|
|
9b4d7d |
continue
|
|
|
9b4d7d |
fi
|
|
|
9b4d7d |
|
|
|
9b4d7d |
while [[ $COUNTSRC -lt ${#SRC[*]} ]];do
|
|
|
9b4d7d |
|
|
|
9b4d7d |
# Update replacements.
|
|
|
9b4d7d |
DST[$COUNTDST]=$(echo ${DST[$COUNTDST]} \
|
|
|
9b4d7d |
| sed -r "s!${SRC[$COUNTSRC]}!${DST[$COUNTSRC]}!g")
|
|
|
9b4d7d |
|
|
|
9b4d7d |
# Increment source counter.
|
|
|
9b4d7d |
COUNTSRC=$(($COUNTSRC + 1))
|
|
|
9b4d7d |
|
|
|
9b4d7d |
done
|
|
|
9b4d7d |
|
|
|
9b4d7d |
# Reset source counter
|
|
|
9b4d7d |
COUNTSRC=0
|
|
|
9b4d7d |
|
|
|
9b4d7d |
# Increment destination counter.
|
|
|
9b4d7d |
COUNTDST=$(($COUNTDST + 1))
|
|
|
9b4d7d |
|
|
|
9b4d7d |
done
|
|
|
ce40cb |
|
|
|
ce40cb |
# Apply replacements for translation markers.
|
|
|
ce40cb |
while [[ ${COUNT} -lt ${#SRC[*]} ]];do
|
|
|
ce40cb |
|
|
|
ce40cb |
# Use sed to replace translation markers inside the design
|
|
|
ce40cb |
# model instance.
|
|
|
28f865 |
sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" ${LOCATION}
|
|
|
ce40cb |
|
|
|
ce40cb |
# Increment counter.
|
|
|
ce40cb |
COUNT=$(($COUNT + 1))
|
|
|
ce40cb |
|
|
|
ce40cb |
done
|
|
|
ce40cb |
|
|
|
ce40cb |
# Unset specific translation markers and specific replacement
|
|
|
ce40cb |
# variables in order to clean them up. Otherwise, undesired values
|
|
|
ce40cb |
# may ramain from one file to another.
|
|
|
ce40cb |
unset SRC
|
|
|
ce40cb |
unset DST
|
|
|
ce40cb |
|
|
|
ce40cb |
}
|