Skip to content

Instantly share code, notes, and snippets.

@Ikhiloya
Last active November 11, 2018 13:39
Show Gist options
  • Select an option

  • Save Ikhiloya/1cd55db3536406549e4958c32320c1f1 to your computer and use it in GitHub Desktop.

Select an option

Save Ikhiloya/1cd55db3536406549e4958c32320c1f1 to your computer and use it in GitHub Desktop.
Controller method to test spring boot internalization
@Autowired
MessageSource messageSource;
@RequestMapping(value = "/get-greeting", method = RequestMethod.GET)
public String greeting() {
/**
* @LocaleContextHolder.getLocale()
* Return the Locale associated with the given user context,if any, or the system default Locale otherwise.
* This is effectively a replacement for Locale.getDefault(), able to optionally respect a user-level Locale setting.
*/
return messageSource.getMessage("good.morning", null, LocaleContextHolder.getLocale());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment