|
|
4e4b4d |
#!/bin/bash
|
|
|
4e4b4d |
#
|
|
|
4e4b4d |
# locale_updateMessageMetadata.sh -- This function sanitates .pot and
|
|
|
4e4b4d |
# .po files to use common translation markers inside top comment.
|
|
|
4e4b4d |
# Later, replacement of common translation markers is applied to set
|
|
|
4e4b4d |
# the final information.
|
|
|
4e4b4d |
#
|
|
|
4e4b4d |
# Copyright (C) 2009-2011 Alain Reguera Delgado
|
|
|
4e4b4d |
#
|
|
|
4e4b4d |
# This program is free software; you can redistribute it and/or
|
|
|
4e4b4d |
# modify it under the terms of the GNU General Public License as
|
|
|
4e4b4d |
# published by the Free Software Foundation; either version 2 of the
|
|
|
4e4b4d |
# License, or (at your option) any later version.
|
|
|
4e4b4d |
#
|
|
|
4e4b4d |
# This program is distributed in the hope that it will be useful, but
|
|
|
4e4b4d |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
4e4b4d |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
4e4b4d |
# General Public License for more details.
|
|
|
4e4b4d |
#
|
|
|
4e4b4d |
# You should have received a copy of the GNU General Public License
|
|
|
4e4b4d |
# along with this program; if not, write to the Free Software
|
|
|
4e4b4d |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
4e4b4d |
# USA.
|
|
|
4e4b4d |
#
|
|
|
4e4b4d |
# ----------------------------------------------------------------------
|
|
|
4e4b4d |
# $Id4
|
|
|
4e4b4d |
# ----------------------------------------------------------------------
|
|
|
4e4b4d |
|
|
|
4e4b4d |
function locale_updateMessageMetadata {
|
|
|
4e4b4d |
|
|
|
4e4b4d |
local COUNT=0
|
|
|
4e4b4d |
local -a SRC
|
|
|
4e4b4d |
local -a DST
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Retrive absolute path of portable object we'll work with.
|
|
|
4e4b4d |
local FILE="$1"
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Define current locale.
|
|
|
4e4b4d |
local CURRENTLOCALE=$(cli_getCurrentLocale)
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Define language name from current locale.
|
|
|
4e4b4d |
local LANGNAME=$(cli_getLangName ${CURRENTLOCALE})
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Define language code from current locale.
|
|
|
4e4b4d |
local LANGCODE=$(cli_getLangCodes ${CURRENTLOCALE})
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Check existence of file before work with it.
|
|
|
4e4b4d |
cli_checkFiles "${FILE}" 'f'
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Define comment patterns. Comment patterns are put inside
|
|
|
4e4b4d |
# portable objects when they are built using xgettext or xml2po
|
|
|
4e4b4d |
# commands.
|
|
|
4e4b4d |
SRC[0]='Project-Id-Version:'
|
|
|
4e4b4d |
SRC[1]='Last-Translator:'
|
|
|
4e4b4d |
SRC[2]='Language-Team:'
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Define comment replacements. Comment replacements is the
|
|
|
4e4b4d |
# convenction we use inside centos-art.sh to set standard
|
|
|
4e4b4d |
# information related to CentOS (e.g., URLs, mail addresses,
|
|
|
4e4b4d |
# release numbers, etc.).
|
|
|
4e4b4d |
DST[0]="\"Project-Id-Version: $(cli_getRepoName "${FILE}" 'dfd')\\\n\""
|
|
|
4e4b4d |
DST[1]="\"Last-Translator: CentOS Documentation SIG <centos-docs@centos.org>\\\n\""
|
|
|
4e4b4d |
DST[2]="\"Language-Team: ${LANGNAME} <centos-docs@${LANGCODE}.centos.org>\\\n\""
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Replace comment patterns with comment replacements.
|
|
|
4e4b4d |
while [[ $COUNT -lt ${#SRC[*]} ]];do
|
|
|
4e4b4d |
sed -i -r "/${SRC[$COUNT]}/c${DST[$COUNT]}" ${FILE}
|
|
|
4e4b4d |
COUNT=$(($COUNT + 1))
|
|
|
4e4b4d |
done
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Apply common replacements to sanitated patterns.
|
|
|
4e4b4d |
cli_replaceTMarkers "${FILE}"
|
|
|
4e4b4d |
|
|
|
4e4b4d |
# Unset array variables to avoid undesired concatenations.
|
|
|
4e4b4d |
unset SRC
|
|
|
4e4b4d |
unset DST
|
|
|
4e4b4d |
|
|
|
4e4b4d |
}
|