Internationalization (i18n) and Localization (l10n) in Java - Quiz

Total: 12 questions

1. 

What are i18n and l10n, and what do these abbreviations stand for?

i18n is an abbreviation of internationalization: the first letter i, the last letter n, and 18 letters in between. l10n shortens localization the same way: l, 10 letters, n. Such abbreviations are called numeronyms.

  • Internationalization is designing an application so that adding a new language doesn't require recompiling and rebuilding it: texts live in properties files, and number, date and currency formats come from the locale.
  • Localization is adapting the application to a specific language and region: translating the UI and documentation, setting up date, currency and number formats.
  • g11n (globalization) is i18n and l10n together; L10n with a capital L is sometimes used so it isn't confused with the digit 1.

In Java, both tasks are tied together by the locale: a java.util.Locale object, a pair of language and region such as en-US.

2. 

What is the difference between internationalization and localization, and which comes first?

i18n comes first. It is done once, during development: the developer makes the code independent of language and region by moving texts to a ResourceBundle and formatting dates with DateTimeFormatter and a locale. This is a code change.

Then l10n is repeated for every new language or market: a translator or developer adds a translation file such as messages_de_DE.properties without touching the code and without recompiling.

Without i18n, localization turns into rewriting the program: you have to find and replace strings across the whole project.

3. 

What depends on the locale besides the UI language, and why can formatter output differ between Java 8 and Java 11+?

The locale changes number separators, the order of date parts and month names, the currency symbol and its position, the first day of the week and the sort order of strings. For example, in Java 11+:

  • the number 1234.5: 1,234.5 (en-US), 1.234,5 (de-DE), 1 234,5 with a non-breaking space (ru-RU);
  • March 8, 2026 (LONG style): March 8, 2026, 8. März 2026, 8 марта 2026 г.;
  • the first day of the week: Sunday in en-US, Monday in de-DE and ru-RU.

Since Java 9, locale data comes from Unicode CLDR by default (JEP 252) instead of the old JRE tables. So the same formatter can produce another currency symbol, another grouping space or a different suffix after the year. Don't compare formatted strings in tests if they were recorded on a different JDK version.

4. 

How do you internationalize a Java application?

  1. Extract the texts. Instead of a string in the code, use a key such as message.welcome defined in messages.properties, messages_de_DE.properties and so on.
  2. Determine the locale from user settings, an HTTP request header or Locale.getDefault().
  3. Load the translations with ResourceBundle.getBundle("messages", locale): it finds the matching file itself and falls back to a more general one if there is no file for that locale.
  4. Format with the locale: print numbers, currencies and dates through NumberFormat, DateTimeFormatter and MessageFormat instead of concatenating strings by hand.
DateTimeFormatter formatter = DateTimeFormatter
        .ofLocalizedDate(FormatStyle.LONG)
        .withLocale(locale);
System.out.println(date.format(formatter));

To add a language, you only need a new locale and a translation file: the JDK supplies month names and formats.

5. 

Which locale does Java use if you don't specify one, and when do you need Locale.ROOT?

Many methods without an explicit locale use Locale.getDefault(). The JVM determines it at startup from the operating system settings; you can override it with -Duser.language=en -Duser.country=US or by calling Locale.setDefault(...). Since Java 7, it is set separately for display (Locale.Category.DISPLAY) and for formatting (Locale.Category.FORMAT).

As a result, the same code behaves differently on a developer's machine and on a server. Process internal data (keys, identifiers, file formats) with Locale.ROOT, and apply the user's locale only to text the user will see:

// with the de-DE default locale "%.2f" gives "1234,50" - Double.parseDouble fails
String fixed = String.format(Locale.ROOT, "%.2f", 1234.5); // "1234.50"
String key = "title".toUpperCase(Locale.ROOT);             // "TITLE" even with a Turkish locale
6. 

Which Java classes are used for internationalization, and what changed in modern Java versions?

No third-party libraries are needed, the standard library has everything:

  • Locale (java.util): a language and region, passed to every formatter;
  • ResourceBundle (java.util): loads translations from .properties files for the right locale;
  • NumberFormat (java.text): numbers, currencies and percentages;
  • DateTimeFormatter (java.time.format): dates and times;
  • MessageFormat (java.text): templates with parameters such as "Found {0} files";
  • Collator (java.text): sorting strings by the alphabet of a specific language;
  • String.format(Locale, ...): string formatting with an explicit locale.

Since Java 9, ResourceBundle reads properties files as UTF-8 (JEP 226), so non-Latin text no longer has to be escaped with the native2ascii tool. Constructors such as new Locale("de", "DE") are deprecated since Java 19: use Locale.of("de", "DE") or Locale.forLanguageTag("de-DE") instead.

7. 

What are i18n and l10n, and what do these abbreviations stand for?

i18n is an abbreviation of internationalization: the first letter i, the last letter n, and 18 letters in between. l10n shortens localization the same way: l, 10 letters, n. Such abbreviations are called numeronyms.

  • Internationalization is designing an application so that adding a new language doesn't require recompiling and rebuilding it: texts live in properties files, and number, date and currency formats come from the locale.
  • Localization is adapting the application to a specific language and region: translating the UI and documentation, setting up date, currency and number formats.
  • g11n (globalization) is i18n and l10n together; L10n with a capital L is sometimes used so it isn't confused with the digit 1.

In Java, both tasks are tied together by the locale: a java.util.Locale object, a pair of language and region such as en-US.

8. 

What is the difference between internationalization and localization, and which comes first?

i18n comes first. It is done once, during development: the developer makes the code independent of language and region by moving texts to a ResourceBundle and formatting dates with DateTimeFormatter and a locale. This is a code change.

Then l10n is repeated for every new language or market: a translator or developer adds a translation file such as messages_de_DE.properties without touching the code and without recompiling.

Without i18n, localization turns into rewriting the program: you have to find and replace strings across the whole project.

9. 

What depends on the locale besides the UI language, and why can formatter output differ between Java 8 and Java 11+?

The locale changes number separators, the order of date parts and month names, the currency symbol and its position, the first day of the week and the sort order of strings. For example, in Java 11+:

  • the number 1234.5: 1,234.5 (en-US), 1.234,5 (de-DE), 1 234,5 with a non-breaking space (ru-RU);
  • March 8, 2026 (LONG style): March 8, 2026, 8. März 2026, 8 марта 2026 г.;
  • the first day of the week: Sunday in en-US, Monday in de-DE and ru-RU.

Since Java 9, locale data comes from Unicode CLDR by default (JEP 252) instead of the old JRE tables. So the same formatter can produce another currency symbol, another grouping space or a different suffix after the year. Don't compare formatted strings in tests if they were recorded on a different JDK version.

10. 

How do you internationalize a Java application?

  1. Extract the texts. Instead of a string in the code, use a key such as message.welcome defined in messages.properties, messages_de_DE.properties and so on.
  2. Determine the locale from user settings, an HTTP request header or Locale.getDefault().
  3. Load the translations with ResourceBundle.getBundle("messages", locale): it finds the matching file itself and falls back to a more general one if there is no file for that locale.
  4. Format with the locale: print numbers, currencies and dates through NumberFormat, DateTimeFormatter and MessageFormat instead of concatenating strings by hand.
DateTimeFormatter formatter = DateTimeFormatter
        .ofLocalizedDate(FormatStyle.LONG)
        .withLocale(locale);
System.out.println(date.format(formatter));

To add a language, you only need a new locale and a translation file: the JDK supplies month names and formats.

11. 

Which locale does Java use if you don't specify one, and when do you need Locale.ROOT?

Many methods without an explicit locale use Locale.getDefault(). The JVM determines it at startup from the operating system settings; you can override it with -Duser.language=en -Duser.country=US or by calling Locale.setDefault(...). Since Java 7, it is set separately for display (Locale.Category.DISPLAY) and for formatting (Locale.Category.FORMAT).

As a result, the same code behaves differently on a developer's machine and on a server. Process internal data (keys, identifiers, file formats) with Locale.ROOT, and apply the user's locale only to text the user will see:

// with the de-DE default locale "%.2f" gives "1234,50" - Double.parseDouble fails
String fixed = String.format(Locale.ROOT, "%.2f", 1234.5); // "1234.50"
String key = "title".toUpperCase(Locale.ROOT);             // "TITLE" even with a Turkish locale
12. 

Which Java classes are used for internationalization, and what changed in modern Java versions?

No third-party libraries are needed, the standard library has everything:

  • Locale (java.util): a language and region, passed to every formatter;
  • ResourceBundle (java.util): loads translations from .properties files for the right locale;
  • NumberFormat (java.text): numbers, currencies and percentages;
  • DateTimeFormatter (java.time.format): dates and times;
  • MessageFormat (java.text): templates with parameters such as "Found {0} files";
  • Collator (java.text): sorting strings by the alphabet of a specific language;
  • String.format(Locale, ...): string formatting with an explicit locale.

Since Java 9, ResourceBundle reads properties files as UTF-8 (JEP 226), so non-Latin text no longer has to be escaped with the native2ascii tool. Constructors such as new Locale("de", "DE") are deprecated since Java 19: use Locale.of("de", "DE") or Locale.forLanguageTag("de-DE") instead.

Page 1 of 1