Last active
December 29, 2018 17:01
-
-
Save linhvovn/23b32460b8d3da5a884f09abc46a0e19 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RequestParamLocaleContextResolver implements LocaleContextResolver{ | |
@Override | |
public LocaleContext resolveLocaleContext(ServerWebExchange exchange) { | |
Locale targetLocale = Locale.getDefault(); | |
List<String> referLang = exchange.getRequest().getQueryParams().get("lang"); | |
if (referLang != null && !referLang.isEmpty()) { | |
String lang = referLang.get(0); | |
targetLocale = Locale.forLanguageTag(lang); | |
} | |
return new SimpleLocaleContext(targetLocale); | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment