Blame Scripts/Functions/Locale/locale_editMessages.sh

348bf4
#!/bin/bash
348bf4
#
348bf4
# locale_editMessages.sh -- This function edits portable objects (.po)
348bf4
# using default text editor.
348bf4
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
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
348bf4
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
348bf4
# General Public License for more details.
348bf4
#
348bf4
# You should have received a copy of the GNU General Public License
348bf4
# along with this program; if not, write to the Free Software
dcd347
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
7ac5a5
#
348bf4
# ----------------------------------------------------------------------
348bf4
# $Id$
348bf4
# ----------------------------------------------------------------------
348bf4
348bf4
function locale_editMessages {
348bf4
fef984
    # Print separator line.
510fad
    cli_printMessage '-' --as-separator-line
fef984
80bc6f
    # Prepare localization working directory to receive translation
80bc6f
    # files.
80bc6f
    if [[ ! -d ${WORKDIR} ]];then
80bc6f
80bc6f
        # Print separator line.
80bc6f
        cli_printMessage "-" --as-separator-line
80bc6f
80bc6f
        # Output action message.
80bc6f
        cli_printMessage "${WORKDIR}" --as-creating-line
80bc6f
80bc6f
        # Create localization working directory making parent
80bc6f
        # directories as needed. Subversion doesn't create directories
80bc6f
        # recursively, so we use the system's `mkdir' command and then
80bc6f
        # subversion to register the changes.
80bc6f
        mkdir -p ${WORKDIR}
80bc6f
80bc6f
        # Commit changes from working copy to central repository only.
80bc6f
        # At this point, changes in the repository are not merged in
80bc6f
        # the working copy, but chages in the working copy do are
80bc6f
        # committed up to repository.
80bc6f
        cli_commitRepoChanges "${L10N_BASEDIR}"
80bc6f
80bc6f
    fi
80bc6f
4aff3a
    local FILES=''
348bf4
518423
    if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/(Manuals|Identity/Models)/.*$" ]];then
559249
559249
        # Define list of locale files for XML-based files.
140fcf
        FILES=$(cli_getFilesList ${WORKDIR} --pattern=".*/messages\.po")
559249
559249
        # Do not create machine objects for XML-based files.
559249
        FLAG_DONT_CREATE_MO='true'
559249
b0fdbc
    elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Scripts$" ]];then
559249
559249
        # Define list of locale files for shell script files.
140fcf
        FILES=$(cli_getFilesList ${WORKDIR} --pattern=".*/${TEXTDOMAIN}\.po")
559249
e89926
    else
559249
559249
        cli_printMessage "`gettext "The path provided does not support localization."`" --as-error-line
559249
4aff3a
    fi
4aff3a
bbac1c
    for FILE in $FILES;do
348bf4
bbac1c
        # Print the file we are editing.
510fad
        cli_printMessage "$FILE" --as-updating-line
bbac1c
bbac1c
        # Use default text editor to edit file.
bbac1c
        eval ${EDITOR} ${FILE}
bbac1c
bbac1c
        # Update machine object (.mo) from portable object (.po).
5a5b08
        ${CLI_FUNCNAME}_updateMessageBinary ${FILE}
bbac1c
bbac1c
    done
348bf4
348bf4
}