Internationalization
Internationalization (i18n) is the process of developing applications and services so that they can be customized for different languages and cultures across the world. It is also called localization. The goal of internationalization or localization is to build applications that can offer content in multiple languages and formats.
Spring Boot has built-in support for internationalization.
Let's build a simple service to understand how we can build internationalization in our APIs.
We would need to add a LocaleResolver
and a message source to our Spring Boot application. The following code snippet should be included in Application.java
:
@Bean public LocaleResolver localeResolver() { SessionLocaleResolver sessionLocaleResolver = new SessionLocaleResolver(); sessionLocaleResolver.setDefaultLocale(Locale.US); return sessionLocaleResolver; } @Bean public ResourceBundleMessageSource messageSource() { ResourceBundleMessageSource...