Blame Scripts/Bash/Functions/Locale/locale_updateMessageShell.sh

878a2b
#!/bin/bash
878a2b
#
878a2b
# locale_updateMessageShell.sh -- This function parses shell scripts
878a2b
# source files under action value and retrives translatable strings in
878a2b
# order to creates/updates both the portable object template (.pot)
878a2b
# and the portable object (.po) related.
878a2b
#
e6bbbf
# Copyright (C) 2009-2013 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_updateMessageShell {
878a2b
878a2b
    # Print separator line.
878a2b
    cli_printMessage '-' --as-separator-line
878a2b
878a2b
    # Define regular expression to match extensions of shell scripts
878a2b
    # we use inside the repository.
878a2b
    local EXTENSION='sh'
878a2b
a3435d
    # Define list of absolute paths to function directories.
a3435d
    local FNDIRS=$(cli_getFilesList ${ACTIONVAL}/Functions \
819c26
        --maxdepth=1 --mindepth=1 --type='d' --pattern="${ACTIONVAL}/${FLAG_FILTER}")
a3435d
a3435d
    for FNDIR in $FNDIRS;do
a3435d
a3435d
        # Define absolute path to directory used as reference to store
a3435d
        # portable objects.
78487b
        local L10N_WORKDIR=$(cli_getLocalizationDir "${FNDIR}")
a3435d
a3435d
        # Prepare working directory to receive translation files.
78487b
        locale_prepareWorkingDirectory ${L10N_WORKDIR}
a3435d
a3435d
        # Define absolute path to file used as reference to create
a3435d
        # portable objects.
78487b
        local MESSAGES="${L10N_WORKDIR}/messages"
a3435d
a3435d
        # Print action message.
a3435d
        cli_printMessage "${MESSAGES}.pot" --as-updating-line
a3435d
a3435d
        # Build list of files to process. When you build the pattern,
a3435d
        # be sure the value passed through `--filter' will be exactly
a3435d
        # evaluated with the extension as prefix. Otherwise it would
a3435d
        # be difficult to match files that share the same characters
a3435d
        # in their file names (e.g., it would be difficult to match
a3435d
        # only `hello.sh' if `hello-world.sh' also exists in the same
a3435d
        # location).
039f63
        local FILES=$(cli_getFilesList ${FNDIR} --pattern="^.+\.${EXTENSION}$")
a3435d
819c26
        # Retrieve translatable strings from shell script files and
a3435d
        # create the portable object template (.pot) from them.
a3435d
        xgettext --output=${MESSAGES}.pot \
b505f1
            --copyright-holder="$(cli_printCopyrightInfo --holder)" \
a3435d
            --width=70 --sort-by-file ${FILES}
a3435d
a3435d
        # Sanitate metadata inside the POT file.
a3435d
        locale_updateMessageMetadata "${MESSAGES}.pot"
a3435d
a3435d
        # Verify, initialize or update portable objects from portable
a3435d
        # object templates.
a3435d
        locale_updateMessagePObjects "${MESSAGES}"
a3435d
a3435d
    done
a3435d
a3435d
    # At this point some changes might be realized inside the PO file,
a3435d
    # so we need to update the related MO file based on recently
a3435d
    # updated PO files here in order for `centos-art.sh' script to
a3435d
    # print out the most up to date revision of localized messages.
a3435d
    # Notice that this is required only if we were localizaing shell
a3435d
    # scripts.
a3435d
    locale_updateMessageBinary
878a2b
878a2b
}