Scrivio Interview library
DesignAdvanced8 min read · updated 12 November 2026

Your product is expanding from English-only to 12 languages, including German, Japanese and Arabic. The Spring Boot backend builds emails, PDFs and error messages with string concatenation. What do you design for internationalization in the backend, and what do you require from teams?

Every piece of user-facing text moves out of the code into Spring message bundles, UTF-8 properties files keyed by message id, and is resolved for the user's Locale, taken from their account setting or from Accept-Language through a LocaleResolver. Messages are parameterized with MessageFormat, or ICU4J MessageFormat where plurals and gender matter, because word order differs between languages; numbers, money and dates are formatted with locale-aware formatters only at the edge, while storage and APIs use neutral formats such as ISO 8601, minor units and UTF-8. Emails and PDFs must handle right-to-left text, text expansion and CJK fonts, and teams follow a translation workflow with a translation management system, pseudo-localization tests and CI checks for missing keys.

Why this question is asked

Going from one language to twelve is one of the few changes that touches almost every screen, email and document a product produces. A backend that builds text with string concatenation is the hardest case, because the English sentence structure is baked into the code. Interviewers ask this design question to see whether we know what really differs between languages, beyond swapping words, and whether we can set rules that many teams can follow without each one rediscovering the problems. In this answer, we will see why concatenation fails, move text into message bundles, resolve the user's locale, handle plurals and formats, prepare emails and PDFs, and set up the workflow and checks teams must follow.

1Why Concatenated Text Cannot Be Translated

Consider a line that builds a notification: "You have " + count + " new messages from " + sender. A translator receives the pieces You have, new messages from, and cannot produce a correct sentence, because German puts the verb in a different place, Japanese puts the sender first, and Arabic reads right to left. The pieces also hide grammar: message must become messages for most counts in English, and Polish needs three different forms depending on the number. So translation is not about replacing words; it is about giving translators whole sentences with named slots they can move.

2Externalize Text Into Message Bundles

Spring's MessageSource reads message bundles: a properties file per language, with the same keys and translated values. Spring Boot configures one automatically for files named messages.properties, messages_de.properties, messages_ja.properties and so on, and reads them as UTF-8 by default.

Java
# messages.properties (English, the fallback)
order.shipped=Hello {0}, your order {1} has shipped.
# messages_de.properties
order.shipped=Hallo {0}, Ihre Bestellung {1} wurde versandt.
# application.properties
spring.messages.basename=messages
spring.messages.fallback-to-system-locale=false
String text = messageSource.getMessage("order.shipped", new Object[] {"Ana", "A-17"}, Locale.GERMAN);
// Hallo Ana, Ihre Bestellung A-17 wurde versandt.

Notice fallback-to-system-locale=false. Without it, a missing language falls back to the server's own locale before the base file, so a Japanese user could receive German text simply because the server runs with a German default. The key itself, order.shipped, describes the purpose, not the English wording, so changing the English sentence later does not change the key.

3Resolving the User's Locale

Inside a web request, Spring uses a LocaleResolver to decide the locale, and the default reads the Accept-Language header that browsers send. For a product with accounts, the user's saved language should win, because a person travelling with a borrowed laptop still wants their own language. So we write a small resolver that checks the account setting first and falls back to Accept-Language, and then to a supported default.

Emails, PDFs and notifications are often produced later, by background jobs where there is no request and LocaleContextHolder is empty. So the locale must be stored with the user and passed explicitly to every method that renders text, rather than read from a thread-local that is only set during web requests.

Step throughChoosing the locale for a message
  1. Is there a logged-in user with a saved language?
    YesUse the saved languageNoCheck the request
  2. Does Accept-Language name a supported language?
    YesUse the best supported matchNoUse the product default, en
  3. Render with MessageSource and the chosen Localepass it explicitly to background jobs too

3 steps in order. Play them, or step through them one at a time.

4Parameterized Messages, Plurals and Gender

Placeholders like {0} let translators reorder the sentence, which solves word order. Plurals need more. English has two forms, one and other, but Polish has one, few, many and other, and Arabic has six forms, including zero and two. The JDK's MessageFormat only has a limited choice format, so for real plural and gender rules we use ICU4J's MessageFormat, which implements the CLDR plural rules for each language.

Java
# messages.properties
inbox.count={count, plural, one {You have # new message} other {You have # new messages}}
# messages_pl.properties
inbox.count={count, plural, one {Masz # nowa wiadomosc} few {Masz # nowe wiadomosci} many {Masz # nowych wiadomosci} other {Masz # wiadomosci}}
new com.ibm.icu.text.MessageFormat(pattern, locale).format(Map.of("count", 3));
// English: You have 3 new messages Polish: the "few" form

Translators write one entry per form their language needs, and the library picks the right one from the number. The same mechanism, with select, handles gender, for example a different phrase for he, she or they. Polish text is shown here without its accented letters only to keep the example in plain ASCII; real bundles hold the full characters in UTF-8.

5Format at the Edge, Store Neutral Values

Numbers, money and dates look different in each locale: 1,234.50 in English is 1.234,50 in German, and dates change order and month names. We format with locale-aware formatters only when producing text for a person, using NumberFormat.getCurrencyInstance(locale) or DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG).withLocale(locale), and in the user's time zone. Everywhere else, in the database, in APIs and in events, values stay neutral: dates and times as ISO 8601 or Instant in UTC, money as an integer number of minor units plus a currency code, and all text as UTF-8, which in MySQL means the utf8mb4 character set. This split means translation never touches stored data, and a value can be shown in any language at any time.

6Emails and PDFs: Direction, Space and Fonts

Arabic is written right to left, so HTML email templates need dir="rtl" on the root element and layouts that mirror, with icons and alignment flipped. PDF generation is harder, because the library must apply the Unicode bidirectional algorithm and shape Arabic letters, which join differently at the start, middle and end of a word, so we must choose a PDF library that supports this and test it with real text. German text is often around 30 percent longer than English, so fixed-width columns and buttons overflow. Japanese needs fonts with CJK glyphs embedded in the PDF, such as the Noto CJK family, or characters render as empty boxes. These are layout decisions, so templates must be designed for them from the start rather than patched per language.

What changes per language in our outputs
ConcernGermanJapaneseArabic
Word order and pluralsVerb moves; 2 plural formsNo plural forms; order differs6 plural forms
Text lengthOften about 30% longerOften shorterVaries
DirectionLeft to rightLeft to rightRight to left, letters join
Fonts in PDFsLatin fonts are fineEmbed a CJK fontFont with Arabic shaping
Number and date formats1.234,50 and 05.03.2024Year firstPossibly Arabic-Indic digits
Each of these is a template and design decision, not a translation task.

7The Workflow Teams Must Follow

The rules for teams are few but strict. No user-facing text is built by concatenation; every string has a key in the bundle, with a comment describing its context for translators. English bundles are the source, and a translation management system, a tool that sends new keys to translators and returns translated files, keeps the other eleven languages in step, through an automated sync with the repository. Development builds can enable a pseudo-locale that wraps every message in brackets and lengthens it by about 30 percent, so untranslated or truncated text is obvious on screen without waiting for real translations.

CI checks complete the picture: a test fails when a key exists in the base bundle but not in a supported language, when a bundle file is not valid UTF-8, or when a message's placeholders do not match between languages. Text that is missing a translation falls back to English in production, but never silently: we log and count it.

8Follow-up questions

How do you handle plural rules such as those in Polish or Arabic?

By not writing plural logic in code at all. Code that says if count equals 1 use the singular is correct only for English-like languages. Instead, the message itself contains the plural forms in ICU's plural syntax, and ICU4J's MessageFormat chooses the category, one, few, many, other and for Arabic also zero and two, using the CLDR rules for the target locale. For Polish, 2, 3 and 4 take the few form, 5 to 21 take many, and 22 to 24 are few again, which no hand-written condition gets right. Translators fill in only the categories their language uses, and we test with sample numbers for each category.

Where should the locale be stored for a user?

As a language tag such as de-DE or ar-EG on the user's profile, chosen at sign-up from the browser's preference and editable in settings. Storing a BCP 47 tag, parsed with Locale.forLanguageTag, keeps it portable between services. Every asynchronous job that renders text for the user, emails, PDFs, push notifications, reads the tag from the profile and passes the Locale explicitly, which makes the output the same whether it is produced in a request or in a batch job at night.

Should error messages from the API be translated?

The API should return a stable machine-readable error code, and optionally a message in the user's language for display. Clients and logs rely on the code, which never changes, while the translated message is produced from the bundle with the request's locale. Spring's ProblemDetail support can carry both, for example a type URI and code plus a localized detail. Logs should stay in one language, usually English, so that operators can search them.

9Conclusion

In this answer, we designed internationalization for a Spring Boot backend moving to 12 languages. Text moves into UTF-8 message bundles resolved by MessageSource for a Locale chosen from the account setting or Accept-Language and passed explicitly to background jobs. Messages are parameterized, with ICU4J handling plurals and gender, values are formatted per locale only at the edge and stored in neutral formats, emails and PDFs are designed for right-to-left text, longer text and CJK fonts, and teams follow a workflow with a translation management system, pseudo-localization and CI checks for missing keys.

What to say in the interviewAbout 90 seconds aloud

Open with

I would start by taking all user-facing text out of the code. Concatenation can't be translated because word order, plurals and gender differ between languages, so every string becomes a key in a Spring message bundle, messages.properties plus one file per language in UTF-8, with fallback to the system locale turned off so the server's own locale never leaks in.

Then, if they want more

The user's locale comes from their saved account setting first, then Accept-Language through a LocaleResolver, and because emails and PDFs are often produced by background jobs, the locale is stored on the user and passed explicitly instead of read from the request context.

Messages use placeholders so translators can reorder them, and for plurals and gender I'd use ICU4J's MessageFormat, since Polish needs one, few and many forms and Arabic has six.

Numbers, currency and dates are formatted with locale-aware formatters only at the edge, while storage and APIs use neutral formats: ISO 8601 and UTC, money in minor units with a currency code, and UTF-8 everywhere, utf8mb4 in MySQL.

Emails and PDFs need right-to-left layouts and Arabic shaping, room for German text about 30 percent longer, and embedded CJK fonts for Japanese.

For teams, the rules are: no concatenated user text, keys with context comments, a translation management system synced with the repository, a pseudo-locale in development to spot hard-coded or truncated text, and CI checks that fail on missing keys or mismatched placeholders.

About this answer

Last updated
12 November 2026
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.
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 "Your product is expanding from English-only to 12 languages, including German, Japanese...": https://scrivio-interview-library.netlify.app/java/strings/96450f98e9/