Blame tcar-scripts-locale/Modules/Directories/directories.sh

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