Blame tcar-scripts-locale/modules/directories/directories.sh

Alain Reguera Delgado f23b0d
#!/bin/bash
Alain Reguera Delgado f23b0d
######################################################################
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#   directories.sh -- This module make a list of all the supported
Alain Reguera Delgado f23b0d
#   files inside the directory provided as argument in the
Alain Reguera Delgado f23b0d
#   command-line. They it passed each file found to files module,
Alain Reguera Delgado f23b0d
#   where they are processed one by one.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
#   Written by:
Alain Reguera Delgado f23b0d
#   * Alain Reguera Delgado <al@centos.org.cu>, 2009-2013
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# Copyright (C) 2009-2013 The CentOS Artwork SIG
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# This program is free software; you can redistribute it and/or modify
Alain Reguera Delgado f23b0d
# it under the terms of the GNU General Public License as published by
Alain Reguera Delgado f23b0d
# the Free Software Foundation; either version 2 of the License, or (at
Alain Reguera Delgado f23b0d
# your option) any later version.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# This program is distributed in the hope that it will be useful, but
Alain Reguera Delgado f23b0d
# WITHOUT ANY WARRANTY; without even the implied warranty of
Alain Reguera Delgado f23b0d
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Alain Reguera Delgado f23b0d
# General Public License for more details.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
# You should have received a copy of the GNU General Public License
Alain Reguera Delgado f23b0d
# along with this program; if not, write to the Free Software
Alain Reguera Delgado f23b0d
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
Alain Reguera Delgado f23b0d
#
Alain Reguera Delgado f23b0d
######################################################################
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
function directories {
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    local FILES=''
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Sanitate non-option arguments to be sure they match the
Alain Reguera Delgado f23b0d
    # directory conventions established by centos-art.sh script
Alain Reguera Delgado f23b0d
    # against source directory locations in the working copy.
Alain Reguera Delgado f23b0d
    local DIRECTORY=$(tcar_checkRepoDirSource ${1})
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Define regular expression used by locale module to determine the
Alain Reguera Delgado f23b0d
    # file extension that it can retrieve translatable strings from,
Alain Reguera Delgado f23b0d
    # when a directory as argument is provided in the command-line.
Alain Reguera Delgado f23b0d
    #
Alain Reguera Delgado f23b0d
    # Don't include file extensions for script files here.
Alain Reguera Delgado f23b0d
    #
Alain Reguera Delgado f23b0d
    # Scripts files shouldn't be localized when a directory has been
Alain Reguera Delgado f23b0d
    # passed argument in the command-line because when we are
Alain Reguera Delgado f23b0d
    # processing directories, each file inside it is processed
Alain Reguera Delgado f23b0d
    # individually.  For example, modules might involve several script
Alain Reguera Delgado f23b0d
    # files but they should have only one PO file for all the files
Alain Reguera Delgado f23b0d
    # they are made of.  Using directory processing would create one
Alain Reguera Delgado f23b0d
    # PO file for each script file in the directory and that is what
Alain Reguera Delgado f23b0d
    # should not happen.  For this reason don't include any file
Alain Reguera Delgado f23b0d
    # extension related to script files here.
Alain Reguera Delgado f23b0d
    #
Alain Reguera Delgado f23b0d
    # Don't include file extensions for asciidoc files here.
Alain Reguera Delgado f23b0d
    #
Alain Reguera Delgado f23b0d
    # Asciidoc documents need configuration files in order to be
Alain Reguera Delgado f23b0d
    # localized in coordination with render module. If you list
Alain Reguera Delgado f23b0d
    # asciidoc documents here, the configuration files won't be read
Alain Reguera Delgado f23b0d
    # and it will be localized in a way that may or may not match the
Alain Reguera Delgado f23b0d
    # way it is produced through render module.
Alain Reguera Delgado f23b0d
    local LOCALE_SUPPORTED_FILES='.+/.+\.(svgz|svg)$'
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Build list of supported files which locale module will extract
Alain Reguera Delgado f23b0d
    # translatable strings from.
Alain Reguera Delgado f23b0d
    if [[ ${LOCALE_FLAG_RECURSIVE} == 'true' ]];then
Alain Reguera Delgado f23b0d
        FILES=$(tcar_getFilesList ${DIRECTORY} \
Alain Reguera Delgado f23b0d
            --type=f --pattern="${LOCALE_SUPPORTED_FILES}" \
Alain Reguera Delgado f23b0d
            | egrep "${TCAR_FLAG_FILTER}")
Alain Reguera Delgado f23b0d
    else
Alain Reguera Delgado f23b0d
        FILES=$(tcar_getFilesList ${DIRECTORY} \
Alain Reguera Delgado f23b0d
            --mindepth=1 --maxdepth=1 --type=f \
Alain Reguera Delgado f23b0d
            --pattern="${LOCALE_SUPPORTED_FILES}" \
Alain Reguera Delgado f23b0d
            | egrep "${TCAR_FLAG_FILTER}")
Alain Reguera Delgado f23b0d
    fi
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Verify found files. In case no file is found, print an error
Alain Reguera Delgado f23b0d
    # message describing it.
Alain Reguera Delgado f23b0d
    tcar_checkFiles -ef ${FILES}
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
    # Execute files module to process files found, one by one.
Alain Reguera Delgado f23b0d
    for FILE in ${FILES};do
Alain Reguera Delgado f23b0d
        tcar_setModuleEnvironment -m 'files' -t 'sibling' -g ${FILE}
Alain Reguera Delgado f23b0d
    done
Alain Reguera Delgado f23b0d
Alain Reguera Delgado f23b0d
}