From 07a113e46ec10a93aa86bac680ab95a5e539840c Mon Sep 17 00:00:00 2001 From: Michael Boelen Date: Tue, 12 Jul 2016 20:32:15 +0200 Subject: Set initial value for language and improve auto detection --- default.prf | 7 +++---- include/profiles | 4 +++- lynis | 7 +++++-- 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/default.prf b/default.prf index f2738c78..0695ec47 100644 --- a/default.prf +++ b/default.prf @@ -33,13 +33,12 @@ compressed-uploads=yes # Show non-zero exit code when warnings are found error-on-warnings=no -# Use Lynis in your own language (available languages: en fr nl) -language=en +# Use Lynis in your own language (by default auto-detected) +language= -# Add your Lynis Enterprise license key here +# Lynis Enterprise license key license-key= - # Defines the role of the system (desktop, server) machine-role=server diff --git a/include/profiles b/include/profiles index 89bd26a5..e0182f03 100644 --- a/include/profiles +++ b/include/profiles @@ -139,7 +139,9 @@ # Language language | lang) LogText "Language set via profile to ${VALUE}" - LANGUAGE="${VALUE}" + if [ ! -z "${VALUE}" ]; then + LANGUAGE="${VALUE}" + fi AddSetting "language" "${LANGUAGE}" "Language" ;; diff --git a/lynis b/lynis index ec1bb961..84989720 100755 --- a/lynis +++ b/lynis @@ -99,8 +99,11 @@ Make sure to execute ${PROGRAM_NAME} from untarred directory or check your insta fi # Auto detection of language based on locale (first two characters). Set to English when nothing found. - LANGUAGE=$(locale | egrep "^LANG=" | cut -d= -f2 | cut -d_ -f1) - if [ "${LANGUAGE}" = "" ]; then LANGUAGE="en"; fi + LANGUAGE=$(locale | egrep "^LANG=" | cut -d= -f2 | cut -d_ -f1 | egrep "^[a-z]{2}$") + if [ -z "${LANGUAGE}" ]; then + #Debug "Result: no (valid) language found, setting to default language (en)" + LANGUAGE="en" + fi # ################################################################################# # -- cgit v1.2.3