From aa04588073efe3509e82fcbc06e8cb1557abaa4d Mon Sep 17 00:00:00 2001 From: Vincenzo Date: Mon, 1 Jul 2024 12:27:47 +0200 Subject: [PATCH] Fix locale handling for search (#21) * Fix locale handling for search * Update BeanConfig.java --- .../it/garambo/retrosearch/configuration/BeanConfig.java | 5 ++++- src/main/resources/application.properties | 2 +- src/main/resources/templates/fragments/header.html | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/java/it/garambo/retrosearch/configuration/BeanConfig.java b/src/main/java/it/garambo/retrosearch/configuration/BeanConfig.java index bba85dd..1064770 100644 --- a/src/main/java/it/garambo/retrosearch/configuration/BeanConfig.java +++ b/src/main/java/it/garambo/retrosearch/configuration/BeanConfig.java @@ -2,6 +2,7 @@ import java.util.List; import java.util.Locale; +import lombok.extern.slf4j.Slf4j; import org.apache.commons.validator.routines.UrlValidator; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -13,6 +14,7 @@ import org.thymeleaf.spring6.SpringTemplateEngine; import org.thymeleaf.spring6.view.ThymeleafViewResolver; +@Slf4j @Configuration @EnableScheduling public class BeanConfig { @@ -39,8 +41,9 @@ public ApplicationSettings applicationSettings( @Bean public SearchSettings searchSettings( - @Value("${retrosearch.search.locales:}") List localeList) { + @Value("${retrosearch.search.locales}") List localeList) { List locales = localeList.stream().map(StringUtils::parseLocaleString).toList(); + log.info("Initialising search locales: {}", locales); return new SearchSettings(locales); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index c7ffc99..a6413e0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,7 +3,7 @@ server.compression.enabled=true server.error.whitelabel.enabled=false retrosearch.encoding=UTF-8 retrosearch.html.version=3.2 -retrosearch.search.locales=${SEARCH_LOCALES:en_US,en_GB,it_IT,de_DE} +retrosearch.search.locales=${SEARCH_LOCALES:en_US,en_GB,it_IT,de_DE,fr_FR,es_ES} retrosearch.news.enable=${NEWS_ACTIVE:false} retrosearch.news.api.key=${NEWS_API_KEY:} retrosearch.news.api.rate.limiter=${NEWS_API_RATE_LIMITER:3000} diff --git a/src/main/resources/templates/fragments/header.html b/src/main/resources/templates/fragments/header.html index 1abd73c..8fa94a6 100644 --- a/src/main/resources/templates/fragments/header.html +++ b/src/main/resources/templates/fragments/header.html @@ -23,9 +23,9 @@

Search Query: - +