Add automatic detection of used language

This commit is contained in:
Michael Boelen 2016-06-11 14:34:21 +02:00
parent 18c3984b20
commit f8b134f3c3
3 changed files with 10 additions and 5 deletions

View File

@ -93,7 +93,6 @@ unset LANG
HOSTID="" HOSTID=""
IDS_IPS_TOOL_FOUND=0 IDS_IPS_TOOL_FOUND=0
IPTABLESBINARY="" IPTABLESBINARY=""
LANGUAGE="en-US"
LINUX_VERSION="" LINUX_VERSION=""
LINUXCONFIGFILE="" LINUXCONFIGFILE=""
LMDBINARY="" LMDBINARY=""

View File

@ -128,6 +128,7 @@
# Language # Language
language | lang) language | lang)
LogText "Language set via profile to ${VALUE}"
LANGUAGE="${VALUE}" LANGUAGE="${VALUE}"
;; ;;

13
lynis
View File

@ -91,12 +91,15 @@ Make sure to execute ${PROGRAM_NAME} from untarred directory or check your insta
done done
# Import translations. First import English to prefill all texts # Import translations. First import English to prefill all texts
if [ ! -f ${DBDIR}/languages/en-US ]; then if [ ! -f ${DBDIR}/languages/en ]; then
echo "Could not find languages directory (file: ${DBDIR}/languages/en-US)" echo "Could not find languages directory (file: ${DBDIR}/languages/en)"
exit 1 exit 1
else else
. ${DBDIR}/languages/en-US . ${DBDIR}/languages/en
fi fi
# Auto detection of language based on locale (first two characters)
LANGUAGE=$(locale | egrep "^LANGUAGE=" | cut -d= -f2 | cut -d_ -f1)
# #
################################################################################# #################################################################################
# #
@ -549,7 +552,8 @@ ${NORMAL}
. ${INCLUDEDIR}/profiles . ${INCLUDEDIR}/profiles
# Import a different language when configured # Import a different language when configured
if [ ! "${LANGUAGE}" = "en-US" ]; then if [ ! "${LANGUAGE}" = "en" ]; then
LogText "Language is set to ${LANGUAGE}"
if [ ! -f ${DBDIR}/languages/${LANGUAGE} ]; then if [ ! -f ${DBDIR}/languages/${LANGUAGE} ]; then
Display "Warning: could not find languages directory (file: ${DBDIR}/languages/${LANGUAGE})" Display "Warning: could not find languages directory (file: ${DBDIR}/languages/${LANGUAGE})"
else else
@ -557,6 +561,7 @@ ${NORMAL}
. ${DBDIR}/languages/${LANGUAGE} . ${DBDIR}/languages/${LANGUAGE}
fi fi
fi fi
LogTextBreak
# #
################################################################################# #################################################################################
# #