|
|
878a2b |
#!/bin/bash
|
|
|
878a2b |
#
|
|
|
878a2b |
# locale_editMessages.sh -- This function edits portable objects (.po)
|
|
|
878a2b |
# using default text editor.
|
|
|
878a2b |
#
|
|
|
878a2b |
# Copyright (C) 2009, 2010, 2011 The CentOS Project
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is free software; you can redistribute it and/or modify
|
|
|
878a2b |
# it under the terms of the GNU General Public License as published by
|
|
|
878a2b |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
|
878a2b |
# your option) any later version.
|
|
|
878a2b |
#
|
|
|
878a2b |
# This program is distributed in the hope that it will be useful, but
|
|
|
878a2b |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
878a2b |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
878a2b |
# General Public License for more details.
|
|
|
878a2b |
#
|
|
|
878a2b |
# You should have received a copy of the GNU General Public License
|
|
|
878a2b |
# along with this program; if not, write to the Free Software
|
|
|
878a2b |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
878a2b |
#
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
# $Id$
|
|
|
878a2b |
# ----------------------------------------------------------------------
|
|
|
878a2b |
|
|
|
878a2b |
function locale_editMessages {
|
|
|
878a2b |
|
|
|
878a2b |
local PO_FILE=''
|
|
|
878a2b |
local PO_FILES=''
|
|
|
878a2b |
|
|
|
feac3d |
# Prepare working directory to receive translation files.
|
|
|
feac3d |
locale_prepareWorkingDirectory
|
|
|
878a2b |
|
|
|
878a2b |
# Define list of PO files to process based on paths provided as
|
|
|
878a2b |
# non-option arguments through centos-art.sh script command-line.
|
|
|
878a2b |
if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/(Manuals|Identity/Models)/.*$" ]];then
|
|
|
878a2b |
|
|
|
878a2b |
# Define list of PO files for XML-based files.
|
|
|
878a2b |
PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --pattern=".*/messages\.po")
|
|
|
878a2b |
|
|
|
878a2b |
# Do not create MO files for XML-based files.
|
|
|
878a2b |
FLAG_DONT_CREATE_MO='true'
|
|
|
878a2b |
|
|
|
feac3d |
elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Scripts/Bash$" ]];then
|
|
|
878a2b |
|
|
|
feac3d |
# Define list of PO files for script files.
|
|
|
878a2b |
PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --pattern=".*/${TEXTDOMAIN}\.po")
|
|
|
878a2b |
|
|
|
878a2b |
else
|
|
|
878a2b |
cli_printMessage "`gettext "The path provided does not support localization."`" --as-error-line
|
|
|
878a2b |
fi
|
|
|
878a2b |
|
|
|
feac3d |
# Verify list of PO files.
|
|
|
feac3d |
if [[ $PO_FILES = "" ]];then
|
|
|
feac3d |
cli_printMessage "`gettext "The path provided hasn't translations yet."`" --as-error-line
|
|
|
feac3d |
else
|
|
|
feac3d |
cli_printMessage '-' --as-separator-line
|
|
|
feac3d |
fi
|
|
|
feac3d |
|
|
|
878a2b |
# Loop through list of PO files to process in order to edit them
|
|
|
878a2b |
# one by one using user's default text editor.
|
|
|
878a2b |
for PO_FILE in ${PO_FILES};do
|
|
|
878a2b |
|
|
|
878a2b |
# Print the file we are editing.
|
|
|
878a2b |
cli_printMessage "${PO_FILE}" --as-updating-line
|
|
|
878a2b |
|
|
|
878a2b |
# Use default text editor to edit the PO file.
|
|
|
878a2b |
eval ${EDITOR} ${PO_FILE}
|
|
|
878a2b |
|
|
|
878a2b |
# At this point some changes might be realized inside the PO
|
|
|
878a2b |
# file, so we need to update the related MO files based on
|
|
|
878a2b |
# recently updated PO files here in order for `centos-art.sh'
|
|
|
878a2b |
# script to print out the most up to date revision of
|
|
|
878a2b |
# localized messages. Notice that this is required only if we
|
|
|
878a2b |
# were localizaing shell scripts.
|
|
|
878a2b |
locale_updateMessageBinary ${PO_FILE}
|
|
|
878a2b |
|
|
|
878a2b |
done
|
|
|
878a2b |
|
|
|
878a2b |
}
|