Quick revision
The short answer
Services should return stable message codes with parameters, and the text for each locale should come from bundles that are built from one translation system rather than edited by hand in 20 repositories. Each service keeps its own bundle for its own messages, a shared library ships one common bundle for cross-cutting errors, CI fails on missing or broken keys, and every service follows the same fallback rule. Messages are always whole, parameterised sentences, never translated fragments glued together.
What to remember
In this answer, we saw that consistency across 20 services comes from a few shared decisions rather than from MessageSource itself: codes in APIs, text rendered only where clients cannot do it, a service bundle plus a common library bundle, translations pulled from one system as build artifacts, CI checks for missing keys and broken patterns, one fallback policy, and whole parameterised sentences.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Services should return stable message codes with parameters, and the text for each locale should come from bundles that are built from one translation system rather than edited by hand in 20 repositories. Each service keeps its own bundle for its own messages, a shared library ships one common bundle for cross-cutting errors, CI fails on missing or broken keys, and every service follows the same fallback rule. Messages are always whole, parameterised sentences, never translated fragments glued together.
Why this question is asked
Going from one language to twelve is rarely hard because of Spring. It is hard because 20 teams will each invent their own way of naming keys, wording errors and handling a missing translation, and the customer sees all of those differences on one screen. Interviewers ask this design question to see whether we can turn a framework feature, MessageSource, into a system that many teams can follow without thinking. In this answer, we will recap how Spring resolves messages, decide where text should be rendered at all, organise bundles across services, connect them to a translation workflow, protect them with CI checks and a fallback policy, and see why concatenating fragments breaks in other languages.
1A Quick Recap of MessageSource and Bundles
In Spring, a MessageSource is the object that turns a message code and a locale into text. Boot auto-configures one when it finds a messages.properties file on the classpath. Each locale has its own file next to it: messages_fr.properties for French, messages_de_CH.properties for Swiss German, and so on. A set of files like this is called a resource bundle.
When we ask for the code order.not_found in locale fr-CA, Spring looks in messages_fr_CA.properties first, then messages_fr.properties, then the base messages.properties. That chain of lookups is the fallback. Parameters are written as {0}, {1} in the text and filled in by java.text.MessageFormat, which also formats numbers and dates for the locale.
Notice that the code is the stable part and the text is replaceable. That single idea drives the whole design that follows.
2Decide Where Text Is Rendered
The first decision is whether backend services should produce translated text at all. For an API consumed by our own web and mobile clients, the cleanest contract is a stable code plus parameters. The client already knows the user's locale, already holds its own UI strings, and can render the message in the same style as the rest of the screen. The service then never needs to know about locales, and adding a thirteenth language does not require deploying 20 services.
There are cases where the service must render text: emails, PDFs, SMS, push notifications and error responses for third-party API consumers who will not translate codes themselves. For those, the service resolves text with MessageSource using the locale taken from the user's profile or the Accept-Language header. So the standard is: always send the code, and send rendered text only where the consumer cannot render it.
This shape fits Spring's ProblemDetail, the RFC 9457 error body Spring Framework 6 and later supports, with code and params added as extra properties. Clients that translate read the code; others show the title.
3Organise Bundles Across 20 Services
Each service keeps its own bundle for messages only it produces, such as payment.card_declined in the payment service. Keys are namespaced by service or domain so that two teams never fight over a key called error.invalid. Cross-cutting messages, such as validation failures, authentication errors, rate limits and the generic something went wrong, live in one common bundle shipped in a shared library jar. Every service lists both bundles, and Spring searches them in order.
The reason for this split is ownership. A team can change its own wording without a platform release, but the message a user sees for an expired session is identical in every service because it literally comes from the same file.
- payment messages_fr_CAservice bundle, most specific locale
- payment messages_frservice bundle, language only
- payment messagesservice bundle, base language
- common-messages_fr_CA / _frshared library bundle
- common-messagesshared base; a miss here is a CI failure
5 layers, from the top down. Step through them one at a time.
Notice fallback-to-system-locale: false. Boot's default is true, which means a missing Polish key on a server whose JVM locale happens to be German shows German text. Setting it to false makes the base file, our chosen default language, the only fallback.
The diagram shows the layers a lookup passes through, from the most specific to the most general.
4Treat Bundles as Build Artifacts From a Translation System
With 12 locales and 20 services, hand-editing properties files does not scale. Translators do not use Git, and engineers cannot judge a Thai sentence. So we connect every repository to one translation management system, a tool where translators see each source string with context, screenshots and length limits. Engineers own only the base language file. A pipeline step pushes new or changed base keys to the system, and pulls finished translations back as generated files.
Those generated files are build artifacts, not source we edit. The service build pulls the latest approved translations for its keys, packages them into the jar, and CI verifies them. Because translation lags behind code, a feature may ship with some locales still falling back to the base language, and that is acceptable only if the fallback policy says so explicitly.
5Test Keys in CI and Define the Fallback Policy
Missing keys are the most common i18n bug, and they are cheap to catch. A unit test can load every bundle, compare its key set with the base file, and check that each message parses with MessageFormat and uses the same parameter numbers as the base. A second check fails the build if code references a key that exists in no bundle.
The fallback policy then says what happens at runtime when a translation is still missing: a specific locale falls back to its language, the language falls back to the base language, and we never show a raw code to a customer. The policy is written once and applied by the shared configuration, so all 20 services behave alike.
6Never Concatenate Translated Fragments
The last rule is the one that breaks most often in real code. Building a sentence from pieces, such as translated("you_have") + count + translated("items_in") + cartName, assumes every language uses English word order. German moves the verb, Japanese puts the count after the noun, and Arabic and Polish have several plural forms. The translator sees only fragments and cannot fix the order.
Plain MessageFormat choice handles simple plurals; for languages with several plural forms many teams use ICU4J's MessageFormat, which knows the plural rules per locale. Either way the translator receives one complete sentence and can reorder it freely.
7Follow-up questions
Should error codes be part of the public API contract?
Yes. Once clients branch on order.not_found, renaming the code is a breaking change, so codes are versioned and documented like any other field. The text, on the other hand, can change at any time, which is exactly why clients should never parse it.
How do you pick the locale in a service that renders text?
For user-triggered requests, Spring's AcceptHeaderLocaleResolver reads Accept-Language. For background work such as a nightly email, there is no request, so the locale must come from the user's stored preference. That is why the user profile should store a locale, and events that trigger messages should carry it.
What about apostrophes in MessageFormat?
A single quote starts a quoted section in MessageFormat, so the French l'article must be written l''article in a pattern with parameters. Translation tools can be configured to escape this automatically, and the CI parse check catches patterns where it was forgotten.
8Conclusion
In this answer, we saw that consistency across 20 services comes from a few shared decisions rather than from MessageSource itself: codes in APIs, text rendered only where clients cannot do it, a service bundle plus a common library bundle, translations pulled from one system as build artifacts, CI checks for missing keys and broken patterns, one fallback policy, and whole parameterised sentences.
Open with
I would start by deciding where text is rendered at all. For our own clients, services return a stable code and parameters, for example order.not_found with the order id, and the client renders it.
Then, if they want more
Services render text only for emails, documents and external API consumers. Then I would split bundles: each service owns a namespaced messages.properties for its own messages, and a shared library ships a common bundle for cross-cutting errors like validation, authentication and rate limits, so those read identically everywhere. Spring's spring.messages.basename lists both. Engineers would only edit the base language.
A pipeline pushes new keys to a translation management system and pulls approved translations back as generated files, so bundles are build artifacts rather than hand-edited source. In CI, a test compares every locale's keys and placeholders with the base file and parses each pattern, so a missing key or broken apostrophe fails the build.
At runtime I would set fallback-to-system-locale to false and define one fallback chain, locale, then language, then base, so no customer ever sees a raw code or a random server language. Finally, I would ban building sentences from translated fragments.
Every message is one complete sentence with parameters, using ICU plural rules where a language needs them, because word order and plural forms differ between languages and a translator cannot fix fragments.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Framework 6
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Core technologies
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "A product is going to 12 locales across 20 services. How would you organise message...": https://scrivio-interview-library.netlify.app/spring-boot/spring-utilities/bd9dc10125/