|
Alain Reguera Delgado |
8f60cb |
#!/bin/bash
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# locale_editMessages.sh -- This function edits portable objects (.po)
|
|
Alain Reguera Delgado |
8f60cb |
# using default text editor.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# Copyright (C) 2009-2013 The CentOS Project
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is free software; you can redistribute it and/or modify
|
|
Alain Reguera Delgado |
8f60cb |
# it under the terms of the GNU General Public License as published by
|
|
Alain Reguera Delgado |
8f60cb |
# the Free Software Foundation; either version 2 of the License, or (at
|
|
Alain Reguera Delgado |
8f60cb |
# your option) any later version.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# This program is distributed in the hope that it will be useful, but
|
|
Alain Reguera Delgado |
8f60cb |
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Alain Reguera Delgado |
8f60cb |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Alain Reguera Delgado |
8f60cb |
# General Public License for more details.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# You should have received a copy of the GNU General Public License
|
|
Alain Reguera Delgado |
8f60cb |
# along with this program; if not, write to the Free Software
|
|
Alain Reguera Delgado |
8f60cb |
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
Alain Reguera Delgado |
8f60cb |
#
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
# $Id$
|
|
Alain Reguera Delgado |
8f60cb |
# ----------------------------------------------------------------------
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
function locale_editMessages {
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify directory passed as non-option argument to be sure it
|
|
Alain Reguera Delgado |
8f60cb |
# supports localization.
|
|
Alain Reguera Delgado |
8f60cb |
locale_isLocalizable "${ACTIONVAL}"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
local PO_FILE=''
|
|
Alain Reguera Delgado |
8f60cb |
local PO_FILES=''
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define location where translation files will be stored in
|
|
Alain Reguera Delgado |
8f60cb |
# without language information in it. The language information is
|
|
Alain Reguera Delgado |
8f60cb |
# put later, when we build the list of files.
|
|
Alain Reguera Delgado |
8f60cb |
local L10N_WORKDIR=$(cli_getLocalizationDir "${ACTIONVAL}" "--no-lang")
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Prepare working directory to receive translation files. Don't do
|
|
Alain Reguera Delgado |
8f60cb |
# this here. It is already done as part the update actions, but we
|
|
Alain Reguera Delgado |
8f60cb |
# need it here for those cases when no update action is run and
|
|
Alain Reguera Delgado |
8f60cb |
# one execute the edit option.
|
|
Alain Reguera Delgado |
8f60cb |
locale_prepareWorkingDirectory ${L10N_WORKDIR}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define list of PO files to process based on paths provided as
|
|
Alain Reguera Delgado |
8f60cb |
# non-option arguments through centos-art.sh script command-line.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ $ACTIONVAL =~ "^${TCAR_WORKDIR}/(Documentation/Models/(Docbook|Svg)|Identity/Models)/.*$" ]];then
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Do not create MO files for XML-based files.
|
|
Alain Reguera Delgado |
8f60cb |
FLAG_DONT_CREATE_MO='true'
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Define list of PO files we want to work with. Don't forget to
|
|
Alain Reguera Delgado |
8f60cb |
# include the language information here.
|
|
Alain Reguera Delgado |
8f60cb |
PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --type="f" \
|
|
Alain Reguera Delgado |
8f60cb |
--pattern=".+/${FLAG_FILTER}/${CLI_LANG_LC}/messages\.po$")
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Verify list of PO files.
|
|
Alain Reguera Delgado |
8f60cb |
if [[ $PO_FILES = "" ]];then
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "`gettext "The path provided hasn't translations yet."`" --as-error-line
|
|
Alain Reguera Delgado |
8f60cb |
else
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage '-' --as-separator-line
|
|
Alain Reguera Delgado |
8f60cb |
fi
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Synchronize changes between repository and working copy. At this
|
|
Alain Reguera Delgado |
8f60cb |
# point, changes in the repository are merged in the working copy
|
|
Alain Reguera Delgado |
8f60cb |
# and changes in the working copy committed up to repository.
|
|
Alain Reguera Delgado |
8f60cb |
cli_synchronizeRepoChanges "${PO_FILES}"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Loop through list of PO files to process in order to edit them
|
|
Alain Reguera Delgado |
8f60cb |
# one by one using user's default text editor.
|
|
Alain Reguera Delgado |
8f60cb |
for PO_FILE in ${PO_FILES};do
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Print the file we are editing.
|
|
Alain Reguera Delgado |
8f60cb |
cli_printMessage "${PO_FILE}" --as-updating-line
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Use default text editor to edit the PO file.
|
|
Alain Reguera Delgado |
8f60cb |
eval ${EDITOR} ${PO_FILE}
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
done
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# At this point some changes might be realized inside the PO file,
|
|
Alain Reguera Delgado |
8f60cb |
# so we need to update the related MO file based on recently
|
|
Alain Reguera Delgado |
8f60cb |
# updated PO files here in order for `centos-art.sh' script to
|
|
Alain Reguera Delgado |
8f60cb |
# print out the most up to date revision of localized messages.
|
|
Alain Reguera Delgado |
8f60cb |
# Notice that this is required only if we were localizing shell
|
|
Alain Reguera Delgado |
8f60cb |
# scripts.
|
|
Alain Reguera Delgado |
8f60cb |
locale_updateMessageBinary
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
# Synchronize changes between repository and working copy. At this
|
|
Alain Reguera Delgado |
8f60cb |
# point, changes in the repository are merged in the working copy
|
|
Alain Reguera Delgado |
8f60cb |
# and changes in the working copy committed up to repository.
|
|
Alain Reguera Delgado |
8f60cb |
cli_synchronizeRepoChanges "${PO_FILES}"
|
|
Alain Reguera Delgado |
8f60cb |
|
|
Alain Reguera Delgado |
8f60cb |
}
|