Blame Scripts/Bash/Functions/cli_getCurrentLocale.sh

4c79b5
#!/bin/bash
4c79b5
#
4c79b5
# cli_getCurrentLocale.sh -- This function checks LANG environment
b88fde
# variable and returns the current locale information in the LL_CC
b88fde
# format.
4c79b5
#
254af5
# Copyright (C) 2009-2011 Alain Reguera Delgado
4c79b5
# 
4c79b5
# This program is free software; you can redistribute it and/or
4c79b5
# modify it under the terms of the GNU General Public License as
4c79b5
# published by the Free Software Foundation; either version 2 of the
4c79b5
# License, or (at your option) any later version.
4c79b5
# 
4c79b5
# This program is distributed in the hope that it will be useful, but
4c79b5
# WITHOUT ANY WARRANTY; without even the implied warranty of
4c79b5
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
4c79b5
# General Public License for more details.
4c79b5
#
4c79b5
# You should have received a copy of the GNU General Public License
4c79b5
# along with this program; if not, write to the Free Software
4c79b5
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
4c79b5
# USA.
4c79b5
# 
4c79b5
# ----------------------------------------------------------------------
418249
# $Id$
4c79b5
# ----------------------------------------------------------------------
4c79b5
4c79b5
function cli_getCurrentLocale {
4c79b5
4c79b5
    local CURRENTLOCALE=''
4c79b5
b88fde
    # Redefine current locale using LL_CC format.
b88fde
    CURRENTLOCALE=$(echo $LANG | sed -r 's!(^[a-z]{2,3}_[A-Z]{2}).+$!\1!')
4c79b5
4c79b5
    # Define centos-art.sh script default current locale. If
4c79b5
    # centos-art.sh script doesn't support current system locale, use
b88fde
    # English language from United States as default current locale.
4c79b5
    if [[ $CURRENTLOCALE == '' ]];then
b88fde
        CURRENTLOCALE='en_US'
4c79b5
    fi
4c79b5
b88fde
    # Output current locale.    
b88fde
    echo "${CURRENTLOCALE}"
4c79b5
4c79b5
}