Blame Scripts/CentOS-Art/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
bc95f7
    local PO_FILE=''
bc95f7
    local PO_FILES=''
bc95f7
bc95f7
    # Prepare localization working directory for receiving translation
80bc6f
    # files.
989abc
    if [[ ! -d ${L10N_WORKDIR} ]];then
80bc6f
80bc6f
        # Print separator line.
80bc6f
        cli_printMessage "-" --as-separator-line
80bc6f
80bc6f
        # Output action message.
989abc
        cli_printMessage "${L10N_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.
989abc
        mkdir -p ${L10N_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
bc95f7
    # Define list of PO files to process based on paths provided as
bc95f7
    # non-option arguments through centos-art.sh script command-line.
518423
    if [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/(Manuals|Identity/Models)/.*$" ]];then
559249
bc95f7
        # Define list of PO files for XML-based files.
bc95f7
        PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --pattern=".*/messages\.po")
559249
bc95f7
        # Do not create MO files for XML-based files.
559249
        FLAG_DONT_CREATE_MO='true'
559249
b0fdbc
    elif [[ $ACTIONVAL =~ "^$(cli_getRepoTLDir)/Scripts$" ]];then
559249
bc95f7
        # Define list of PO files for shell scripts.
bc95f7
        PO_FILES=$(cli_getFilesList ${L10N_WORKDIR} --pattern=".*/${TEXTDOMAIN}\.po")
559249
e89926
    else
559249
        cli_printMessage "`gettext "The path provided does not support localization."`" --as-error-line
4aff3a
    fi
4aff3a
bc95f7
    # Loop through list of PO files to process in order to edit them
bc95f7
    # one by one using user's default text editor.
bc95f7
    for PO_FILE in ${PO_FILES};do
348bf4
bbac1c
        # Print the file we are editing.
bc95f7
        cli_printMessage "${PO_FILE}" --as-updating-line
bc95f7
bc95f7
        # Use default text editor to edit the PO file.
bc95f7
        eval ${EDITOR} ${PO_FILE}
bc95f7
bc95f7
        # At this point some changes might be realized inside the PO
bc95f7
        # file, so we need to update the related MO files based on
bc95f7
        # recently updated PO files here in order for `centos-art.sh'
bc95f7
        # script to print out the most up to date revision of
bc95f7
        # localized messages. Notice that this is required only if we
bc95f7
        # were localizaing shell scripts.
bc95f7
        locale_updateMessageBinary ${PO_FILE}
bbac1c
bbac1c
    done
348bf4
348bf4
}