Spring WebFlux Rest API internationalization i18n

Eric Anicet
4 min readApr 17, 2023

The purpose of this story is to explain how to configure and handles internationalization in a Spring WebFlux Rest API.

Photo by Lucas George Wendt on Unsplash

· Prerequisites
· Overview
· What is Internationalization?
· Getting Started
MessageSource Bean
Custom class for LocaleContextResolver
MessageTranslator class
Translation files
· Testing
· Conclusion
· References

Prerequisites

This is the list of all the prerequisites for following this story:

  • Java 17
  • Spring Boot / Starter WebFlux 3.0.5
  • Maven 3.6.3
  • Postman

Overview

When you produce public APIs, you don’t know which clients will consume your services, so it’s important to standardize your API’s return messages so you can communicate effectively with your consumers.

The Java Platform provides a rich set of APIs for developing global applications. These internationalization APIs are based on the Unicode standard and include the ability to adapt text, numbers, dates, currency, and user-defined objects to any country’s conventions.

What is Internationalization?

If you internationalize, you design or develop your content, application, specification, and so on, in a way that ensures it will work well for, or can be easily adapted for, users from any culture, region, or language.

The word ‘Internationalization’ is often abbreviated to ‘i18n’. This is widely used abbreviation, derived from the fact that there are 18 letters between the ‘i’ and the ’n’. — https://www.w3.org/standards/webdesign/i18n

Getting Started

We will start by creating a simple Spring Boot project from start.spring.io, with the…

--

--