diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java index bc007c00b..b8f84b022 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/FessConfig.java @@ -426,6 +426,9 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction /** The key of the configuration. e.g. location */ String QUERY_GEO_FIELDS = "query.geo.fields"; + /** The key of the configuration. e.g. browser_lang */ + String QUERY_BROWSER_LANG_PARAMETER_NAME = "query.browser.lang.parameter.name"; + /** The key of the configuration. e.g. true */ String QUERY_REPLACE_TERM_WITH_PREFIX_QUERY = "query.replace.term.with.prefix.query"; @@ -2282,6 +2285,13 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction */ String getQueryGeoFields(); + /** + * Get the value for the key 'query.browser.lang.parameter.name'.
+ * The value is, e.g. browser_lang
+ * @return The value of found property. (NotNull: if not found, exception but basically no way) + */ + String getQueryBrowserLangParameterName(); + /** * Get the value for the key 'query.replace.term.with.prefix.query'.
* The value is, e.g. true
@@ -5044,6 +5054,10 @@ public interface FessConfig extends FessEnv, org.codelibs.fess.mylasta.direction return get(FessConfig.QUERY_GEO_FIELDS); } + public String getQueryBrowserLangParameterName() { + return get(FessConfig.QUERY_BROWSER_LANG_PARAMETER_NAME); + } + public String getQueryReplaceTermWithPrefixQuery() { return get(FessConfig.QUERY_REPLACE_TERM_WITH_PREFIX_QUERY); } diff --git a/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessUserLocaleProcessProvider.java b/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessUserLocaleProcessProvider.java index 4fd30c260..730b1202f 100644 --- a/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessUserLocaleProcessProvider.java +++ b/src/main/java/org/codelibs/fess/mylasta/direction/sponsor/FessUserLocaleProcessProvider.java @@ -17,17 +17,24 @@ package org.codelibs.fess.mylasta.direction.sponsor; import java.util.Locale; +import org.apache.commons.lang3.LocaleUtils; +import org.codelibs.core.lang.StringUtil; +import org.codelibs.fess.mylasta.direction.FessConfig; +import org.codelibs.fess.util.ComponentUtil; import org.dbflute.optional.OptionalObject; import org.dbflute.optional.OptionalThing; import org.dbflute.util.DfTypeUtil; import org.lastaflute.web.ruts.process.ActionRuntime; import org.lastaflute.web.servlet.request.RequestManager; import org.lastaflute.web.servlet.request.UserLocaleProcessProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @author jflute */ public class FessUserLocaleProcessProvider implements UserLocaleProcessProvider { + private static final Logger logger = LoggerFactory.getLogger(FessUserLocaleProcessProvider.class); @Override public boolean isAcceptCookieLocale() { @@ -36,7 +43,16 @@ public class FessUserLocaleProcessProvider implements UserLocaleProcessProvider @Override public OptionalThing findBusinessLocale(final ActionRuntime runtimeMeta, final RequestManager requestManager) { - return OptionalObject.empty(); // to next determination + final FessConfig fessConfig = ComponentUtil.getFessConfig(); + final String name = fessConfig.getQueryBrowserLangParameterName(); + if (StringUtil.isNotBlank(name)) { + try { + return requestManager.getParameter(name).filter(StringUtil::isNotBlank).map(LocaleUtils::toLocale); + } catch (Exception e) { + logger.debug("Failed to parse a value of " + name + ".", e); + } + } + return OptionalObject.empty(); } @Override diff --git a/src/main/resources/fess_config.properties b/src/main/resources/fess_config.properties index b90c2d333..37fcc60ee 100644 --- a/src/main/resources/fess_config.properties +++ b/src/main/resources/fess_config.properties @@ -202,6 +202,7 @@ index.indices.timeout=1m # query query.max.length=1000 query.geo.fields=location +query.browser.lang.parameter.name=browser_lang query.replace.term.with.prefix.query=true query.highlight.fragment.size=100 query.max.search.result.offset=100000