Blame Scripts/Functions/cli_hasLocalization.sh

a82694
#!/bin/bash
a82694
#
a82694
# cli_hasLocalization.sh -- This function determines whether a file or
a82694
# directory can have translation messages or not. This is the way we
a82694
# standardize what locations can be localized and what cannot inside
a82694
# the repository.
a82694
#
a82694
# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG
a82694
#
a82694
# This program is free software; you can redistribute it and/or modify
a82694
# it under the terms of the GNU General Public License as published by
a82694
# the Free Software Foundation; either version 2 of the License, or (at
a82694
# your option) any later version.
a82694
#
a82694
# This program is distributed in the hope that it will be useful, but
a82694
# WITHOUT ANY WARRANTY; without even the implied warranty of
a82694
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
a82694
# General Public License for more details.
a82694
#
a82694
# You should have received a copy of the GNU General Public License
a82694
# along with this program; if not, write to the Free Software
a82694
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
a82694
#
a82694
# ----------------------------------------------------------------------
a82694
# $Id$
a82694
# ----------------------------------------------------------------------
a82694
a82694
function cli_hasLocalization {
a82694
a82694
    local DIR=''
a82694
    local -a DIRS
a82694
a82694
    # Initialize default value returned by this function.
a82694
    local HASL10N='false'
a82694
a82694
    # Initialize location will use as reference to determine whether
a82694
    # it can have translation messages or not.
a82694
    local LOCATION="$1"
a82694
a82694
    # Redefine location to be sure we'll always evaluate a directory,
a82694
    # as reference location.
a82694
    if [[ -f $LOCATION ]];then
a82694
        LOCATION=$(dirname $LOCATION)
a82694
    fi
a82694
a82694
    # Verify location existence. If it doesn't exist we cannot go on.
a82694
    cli_checkFiles $LOCATION -d
a82694
a82694
    # Define regular expresion list of all directories inside the
a82694
    # repository that can have translation. These are the
a82694
    # locale-specific directories will be created for.
a82694
    DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Identity/Models/Themes/[[:alnum:]-]+/(Concept|Posters|Distro/$(cli_getPathComponent --release-pattern))/(Anaconda|Media)"
a82694
    DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Manuals/[[:alnum:]-]+/Docbook"
60288e
    DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Scripts$"
a82694
a82694
    # Verify location passed as first argument agains the list of
a82694
    # directories that can have translation messages. By default, the
a82694
    # location passed as first argument is considered as a location
a82694
    # that cannot have translation messages until a positive answer
a82694
    # says otherwise.
a82694
    for DIR in ${DIRS[@]};do
a82694
        if [[ $LOCATION =~ $DIR ]];then
a82694
            HASL10N='true'
a82694
            break
a82694
        fi
a82694
    done
a82694
a82694
    # Output final answer to all verifications. 
a82694
    echo "$HASL10N"
a82694
a82694
}