# HG changeset patch # User Mike Becker # Date 1627986130 -7200 # Node ID 785820da6485ddf057ee336399bc7218d2f24f6b # Parent 479dd7993ef9067673e6605ce241498d124345a6 fixes response locale not set for new sessions diff -r 479dd7993ef9 -r 785820da6485 src/main/kotlin/de/uapcore/lightpit/AbstractServlet.kt --- a/src/main/kotlin/de/uapcore/lightpit/AbstractServlet.kt Mon Aug 02 17:04:17 2021 +0200 +++ b/src/main/kotlin/de/uapcore/lightpit/AbstractServlet.kt Tue Aug 03 12:22:10 2021 +0200 @@ -104,6 +104,7 @@ val reqLocale = req.locale val sessionLocale = if (availableLanguages.contains(reqLocale)) reqLocale else availableLanguages.first() session.setAttribute(Constants.SESSION_ATTR_LANGUAGE, sessionLocale) + resp.locale = sessionLocale logger().debug( "Setting language for new session {}: {}", session.id, sessionLocale.displayLanguage ) @@ -176,7 +177,7 @@ protected fun availableLanguages(): List { val langTags = servletContext.getInitParameter(Constants.CTX_ATTR_LANGUAGES)?.split(",")?.map(String::trim) ?: emptyList() val locales = langTags.map(Locale::forLanguageTag).filter { it.language.isNotEmpty() } - return if (locales.isEmpty()) listOf(Locale.ENGLISH) else locales + return locales.ifEmpty { listOf(Locale.ENGLISH) } } }