myvesta/bin/v-change-sys-language
2016-06-09 16:55:35 +03:00

58 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# info: change sys language
# options: LANGUAGE
#
# The function for changing system language.
#----------------------------------------------------------#
# Variable&Function #
#----------------------------------------------------------#
# Argument definition
language=$1
# Includes
source $VESTA/func/main.sh
source $VESTA/conf/vesta.conf
is_language_valid() {
if [ ! -e "$VESTA/web/inc/i18n/$language.php" ]; then
echo "Error: language file $language doesn't exist"
log_event "$E_NOTEXIST $ARGUMENTS"
exit $E_NOTEXIST
fi
}
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
check_args '1' "$#" 'LANGUAGE'
is_format_valid 'language'
is_language_valid $language
#----------------------------------------------------------#
# Action #
#----------------------------------------------------------#
# Change language
if [ -z "$(grep LANGUAGE $VESTA/conf/vesta.conf)" ]; then
echo "LANGUAGE='$language'" >> $VESTA/conf/vesta.conf
else
sed -i "s/LANGUAGE=.*/LANGUAGE='$language'/g" $VESTA/conf/vesta.conf
fi
#----------------------------------------------------------#
# Vesta #
#----------------------------------------------------------#
# Logging
log_event "$OK" "$ARGUMENTS"
exit