Blame Scripts/centos-art/Functions/cli_isLocalized.sh

a82694
#!/bin/bash
a82694
#
99fa4a
# cli_isLocalized.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
#
2fe9b7
# Copyright (C) 2009, 2010, 2011 The CentOS Project
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
99fa4a
function cli_isLocalized {
a82694
a82694
    local DIR=''
a82694
    local -a DIRS
a82694
a82694
    # Initialize default value returned by this function.
99fa4a
    local LOCALIZED='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.
f65de9
    DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Identity/Models/Themes/[[:alnum:]-]+/(Distro/$(\
f65de9
        cli_getPathComponent --release-pattern)/Anaconda|Concept|Posters|Media)"
6d75c5
    DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Manuals/[[:alnum:]-]+$"
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
99fa4a
            LOCALIZED='true'
a82694
            break
a82694
        fi
a82694
    done
a82694
a82694
    # Output final answer to all verifications. 
99fa4a
    echo "$LOCALIZED"
a82694
a82694
}