fix #797 improve Locale handling

This commit is contained in:
Shinsuke Sugaya 2016-11-23 23:31:09 +09:00
parent 32110442d5
commit 5fe3bfe99e
8 changed files with 18 additions and 25 deletions

View file

@ -39,7 +39,6 @@ import org.lastaflute.web.Execute;
import org.lastaflute.web.response.HtmlResponse;
import org.lastaflute.web.response.render.RenderData;
import org.lastaflute.web.ruts.process.ActionRuntime;
import org.lastaflute.web.util.LaRequestUtil;
/**
* @author shinsuke
@ -274,7 +273,7 @@ public class AdminFileauthAction extends FessAdminAction {
protected void registerProtocolSchemeItems(final RenderData data) {
final List<Map<String, String>> itemList = new ArrayList<>();
final Locale locale = LaRequestUtil.getRequest().getLocale();
final Locale locale = ComponentUtil.getRequestManager().getUserLocale();
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.file_auth_scheme_samba"), Constants.SAMBA));
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.file_auth_scheme_ftp"), Constants.FTP));
RenderDataUtil.register(data, "protocolSchemeItems", itemList);

View file

@ -132,7 +132,7 @@ public class ListForm implements SearchRequestParams {
@Override
public Locale getLocale() {
return LaRequestUtil.getRequest().getLocale();
return ComponentUtil.getRequestManager().getUserLocale();
}
@Override

View file

@ -39,7 +39,6 @@ import org.lastaflute.web.Execute;
import org.lastaflute.web.response.HtmlResponse;
import org.lastaflute.web.response.render.RenderData;
import org.lastaflute.web.ruts.process.ActionRuntime;
import org.lastaflute.web.util.LaRequestUtil;
/**
* @author shinsuke
@ -275,7 +274,7 @@ public class AdminWebauthAction extends FessAdminAction {
protected void registerProtocolSchemeItems(final RenderData data) {
final List<Map<String, String>> itemList = new ArrayList<>();
final Locale locale = LaRequestUtil.getRequest().getLocale();
final Locale locale = ComponentUtil.getRequestManager().getUserLocale();
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.webauth_scheme_basic"), Constants.BASIC));
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.webauth_scheme_digest"), Constants.DIGEST));
itemList.add(createItem(ComponentUtil.getMessageManager().getMessage(locale, "labels.webauth_scheme_ntlm"), Constants.NTLM));

View file

@ -41,6 +41,7 @@ import org.codelibs.fess.helper.SystemHelper;
import org.codelibs.fess.helper.UserInfoHelper;
import org.codelibs.fess.helper.ViewHelper;
import org.codelibs.fess.thumbnail.ThumbnailManager;
import org.codelibs.fess.util.ComponentUtil;
import org.dbflute.optional.OptionalThing;
import org.lastaflute.web.login.LoginManager;
import org.lastaflute.web.response.ActionResponse;
@ -118,7 +119,7 @@ public abstract class FessSearchAction extends FessBaseAction {
runtime.registerData("labelTypeItems", labelTypeItems);
runtime.registerData("displayLabelTypeItems", labelTypeItems != null && !labelTypeItems.isEmpty());
Locale locale = request.getLocale();
Locale locale = ComponentUtil.getRequestManager().getUserLocale();
if (locale == null) {
locale = Locale.ENGLISH;
}

View file

@ -129,7 +129,7 @@ public class SearchForm implements SearchRequestParams {
@Override
public Locale getLocale() {
return LaRequestUtil.getRequest().getLocale();
return ComponentUtil.getRequestManager().getUserLocale();
}
@Override

View file

@ -21,7 +21,6 @@ import org.codelibs.fess.es.config.bsentity.BsCrawlingInfoParam;
import org.codelibs.fess.es.config.exbhv.CrawlingInfoBhv;
import org.codelibs.fess.util.ComponentUtil;
import org.dbflute.optional.OptionalEntity;
import org.lastaflute.web.util.LaRequestUtil;
/**
* @author ESFlute (using FreeGen)
@ -59,7 +58,7 @@ public class CrawlingInfoParam extends BsCrawlingInfoParam {
}
public String getKeyMsg() {
final Locale locale = LaRequestUtil.getRequest().getLocale();
final Locale locale = ComponentUtil.getRequestManager().getUserLocale();
final String message = ComponentUtil.getMessageManager().getMessage(locale, "labels.crawling_info_" + getKey());
if (message == null || message.startsWith("???")) {
return getKey();

View file

@ -50,7 +50,6 @@ import org.codelibs.fess.util.ComponentUtil;
import org.lastaflute.web.TypicalAction;
import org.lastaflute.web.ruts.process.ActionRuntime;
import org.lastaflute.web.servlet.request.RequestManager;
import org.lastaflute.web.util.LaRequestUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -176,19 +175,15 @@ public class SystemHelper {
public String getHelpLink(final String name) {
final String url = ComponentUtil.getFessConfig().getOnlineHelpBaseLink() + name + "-guide.html";
return LaRequestUtil
.getOptionalRequest()
.map(request -> {
final Locale locale = request.getLocale();
if (locale != null) {
final String lang = locale.getLanguage();
if (ComponentUtil.getFessConfig().isOnlineHelpSupportedLang(lang)) {
return url.replaceFirst("\\{lang\\}", lang).replaceFirst("\\{version\\}",
Constants.MAJOR_VERSION + "." + Constants.MINOR_VERSION);
}
}
return getDefaultHelpLink(url);
}).orElse(getDefaultHelpLink(url));
final Locale locale = ComponentUtil.getRequestManager().getUserLocale();
if (locale != null) {
final String lang = locale.getLanguage();
if (ComponentUtil.getFessConfig().isOnlineHelpSupportedLang(lang)) {
return url.replaceFirst("\\{lang\\}", lang).replaceFirst("\\{version\\}",
Constants.MAJOR_VERSION + "." + Constants.MINOR_VERSION);
}
}
return getDefaultHelpLink(url);
}
protected String getDefaultHelpLink(final String url) {

View file

@ -317,7 +317,7 @@ public class ViewHelper {
}
public String getPagePath(final String page) {
final Locale locale = LaRequestUtil.getRequest().getLocale();
final Locale locale = ComponentUtil.getRequestManager().getUserLocale();
final String lang = locale.getLanguage();
final String country = locale.getCountry();
@ -378,7 +378,7 @@ public class ViewHelper {
final FileTemplateLoader loader = new FileTemplateLoader(ResourceUtil.getViewTemplatePath().toFile());
final Handlebars handlebars = new Handlebars(loader);
Locale locale = LaRequestUtil.getRequest().getLocale();
Locale locale = ComponentUtil.getRequestManager().getUserLocale();
if (locale == null) {
locale = Locale.ENGLISH;
}