Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save linhvovn/23b32460b8d3da5a884f09abc46a0e19 to your computer and use it in GitHub Desktop.
Save linhvovn/23b32460b8d3da5a884f09abc46a0e19 to your computer and use it in GitHub Desktop.
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