diff --git a/Scripts/Functions/Locale/locale.sh b/Scripts/Functions/Locale/locale.sh index 825ac62..8ab868f 100755 --- a/Scripts/Functions/Locale/locale.sh +++ b/Scripts/Functions/Locale/locale.sh @@ -80,7 +80,7 @@ function locale { # Verify whether the directory provided can have localization # messages or not. - if [[ ! $(cli_hasLocalization $ACTIONVAL) == 'true' ]];then + if [[ ! $(cli_isLocalized $ACTIONVAL) == 'true' ]];then cli_printMessage "`gettext "The path provided doesn't support localization."`" --as-error-line fi diff --git a/Scripts/Functions/Render/render_getDirOutput.sh b/Scripts/Functions/Render/render_getDirOutput.sh index 64b414a..92a864e 100755 --- a/Scripts/Functions/Render/render_getDirOutput.sh +++ b/Scripts/Functions/Render/render_getDirOutput.sh @@ -60,7 +60,7 @@ function render_getDirOutput { # duplicating content (e.g., icons, brands, etc.) which doesn't # have any translation, nor any need to be translated. if [[ ! $(cli_getCurrentLocale) =~ '^en' ]];then - if [[ $(cli_hasLocalization $TEMPLATE) == 'true' ]];then + if [[ $(cli_isLocalized $TEMPLATE) == 'true' ]];then OUTPUT=${OUTPUT}/$(cli_getCurrentLocale) fi fi diff --git a/Scripts/Functions/cli_hasLocalization.sh b/Scripts/Functions/cli_hasLocalization.sh deleted file mode 100755 index 6f39c49..0000000 --- a/Scripts/Functions/cli_hasLocalization.sh +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/bash -# -# cli_hasLocalization.sh -- This function determines whether a file or -# directory can have translation messages or not. This is the way we -# standardize what locations can be localized and what cannot inside -# the repository. -# -# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or (at -# your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_hasLocalization { - - local DIR='' - local -a DIRS - - # Initialize default value returned by this function. - local HASL10N='false' - - # Initialize location will use as reference to determine whether - # it can have translation messages or not. - local LOCATION="$1" - - # Redefine location to be sure we'll always evaluate a directory, - # as reference location. - if [[ -f $LOCATION ]];then - LOCATION=$(dirname $LOCATION) - fi - - # Verify location existence. If it doesn't exist we cannot go on. - cli_checkFiles $LOCATION -d - - # Define regular expresion list of all directories inside the - # repository that can have translation. These are the - # locale-specific directories will be created for. - DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Identity/Models/Themes/[[:alnum:]-]+/(Concept|Posters|Distro/$(cli_getPathComponent --release-pattern))/(Anaconda|Media)" - DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Manuals/[[:alnum:]-]+$" - DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Scripts$" - - # Verify location passed as first argument agains the list of - # directories that can have translation messages. By default, the - # location passed as first argument is considered as a location - # that cannot have translation messages until a positive answer - # says otherwise. - for DIR in ${DIRS[@]};do - if [[ $LOCATION =~ $DIR ]];then - HASL10N='true' - break - fi - done - - # Output final answer to all verifications. - echo "$HASL10N" - -} diff --git a/Scripts/Functions/cli_isLocalized.sh b/Scripts/Functions/cli_isLocalized.sh new file mode 100755 index 0000000..b04b2f7 --- /dev/null +++ b/Scripts/Functions/cli_isLocalized.sh @@ -0,0 +1,71 @@ +#!/bin/bash +# +# cli_isLocalized.sh -- This function determines whether a file or +# directory can have translation messages or not. This is the way we +# standardize what locations can be localized and what cannot inside +# the repository. +# +# Copyright (C) 2009, 2010, 2011 The CentOS Artwork SIG +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or (at +# your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_isLocalized { + + local DIR='' + local -a DIRS + + # Initialize default value returned by this function. + local LOCALIZED='false' + + # Initialize location will use as reference to determine whether + # it can have translation messages or not. + local LOCATION="$1" + + # Redefine location to be sure we'll always evaluate a directory, + # as reference location. + if [[ -f $LOCATION ]];then + LOCATION=$(dirname $LOCATION) + fi + + # Verify location existence. If it doesn't exist we cannot go on. + cli_checkFiles $LOCATION -d + + # Define regular expresion list of all directories inside the + # repository that can have translation. These are the + # locale-specific directories will be created for. + DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Identity/Models/Themes/[[:alnum:]-]+/(Concept|Posters|Distro/$(cli_getPathComponent --release-pattern))/(Anaconda|Media)" + DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Manuals/[[:alnum:]-]+$" + DIRS[++((${#DIRS[*]}))]="$(cli_getRepoTLDir)/Scripts$" + + # Verify location passed as first argument agains the list of + # directories that can have translation messages. By default, the + # location passed as first argument is considered as a location + # that cannot have translation messages until a positive answer + # says otherwise. + for DIR in ${DIRS[@]};do + if [[ $LOCATION =~ $DIR ]];then + LOCALIZED='true' + break + fi + done + + # Output final answer to all verifications. + echo "$LOCALIZED" + +}