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
#
03486a
# Copyright (C) 2009, 2010, 2011, 2012 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 \
a3435d
        --maxdepth=1 --mindepth=1 --type='d' --pattern="/${FLAG_FILTER}$")
a3435d
a3435d
    for FNDIR in $FNDIRS;do
a3435d
a3435d
        # Define function name.
a3435d
        local FNNAME=$(basename $FNDIR)
a3435d
a3435d
        # Define absolute path to directory used as reference to store
a3435d
        # portable objects.
a3435d
        local L10N_DIR=${L10N_WORKDIR}/Functions/${FNNAME}
a3435d
a3435d
        # Prepare working directory to receive translation files.
a3435d
        locale_prepareWorkingDirectory ${L10N_DIR}
a3435d
a3435d
        # Define absolute path to file used as reference to create
a3435d
        # portable objects.
a3435d
        local MESSAGES="${L10N_DIR}/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).
a3435d
        local FILES=$(cli_getFilesList ${FNDIR} --pattern="\.${EXTENSION}$")
a3435d
a3435d
        # Retrive translatable strings from shell script files and
a3435d
        # create the portable object template (.pot) from them.
a3435d
        xgettext --output=${MESSAGES}.pot \
a3435d
            --copyright-holder="${COPYRIGHT_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
}