Skip to content
Pauta1.4.1

Internationalization

Reference: Editora’s i18n/Messages.java (tr, and available() behind the Settings language picker), the catalogs in src/main/resources/com/editora/i18n/, and i18n/MessagesTest.java, which holds them in step.

Every app ships at least these six. They are a floor, not the set: an app SHOULD add languages as people ask for them, and a new app can start with more.

LanguageCatalog
English (base)messages.properties
Spanishmessages_es.properties
Portuguesemessages_pt.properties
Frenchmessages_fr.properties
Italianmessages_it.properties
Germanmessages_de.properties

Adding a language:

  • Add messages_<code>.properties with every key, and the language to the Settings language picker. The parity test (translationCatalogsHaveExactlyTheBaseKeySet) then holds it to the same keys as the others.
  • Translate for real; do not ship English values in another language’s catalog. No test catches an English value, so this one is checked in review.
  • Check the layout in the new language at 1024 px wide. German is today’s longest; rows must wrap, never cut. Also checked by eye, in the running app (see Quality).
  • Scripts beyond Latin need more than strings. Chinese, Japanese and Korean need a font fallback, because Inter has no CJK glyphs. Arabic and Hebrew need NodeOrientation.RIGHT_TO_LEFT on every scene. No app in the family ships such a language yet, so there is no code to copy.
  • Never pass a raw English literal to a control: tr("some.key") from one Messages class. A test (everyLiteralKeyUsedInTheSourcesExists) fails when a tr key is missing from the base catalog.
  • Every language has a real translation of every key. A test fails the build when a key is missing in any catalog (translationCatalogsHaveExactlyTheBaseKeySet, translationsAreNonEmptyAndDistinctFromKeys).
  • MessageFormat rules: in a value with a placeholder, double literal apostrophes; identifiers such as line numbers and ports use {0,number,#} so they are not digit-grouped. Held by aValueWithAPlaceholderNeverHasALoneApostrophe, aValueWithoutAPlaceholderNeverDoublesAnApostrophe and identifierArgumentsAreNeverDigitGrouped.
  • Untranslated on purpose: technical identifiers, --help and --version text (App.java’s usage text).
Editora with a Spanish interface
Editora in Spanish: menus, tool windows and the status bar all come from the catalogs.
Torrenta with a Spanish interface
Torrenta in Spanish.

Pauta 1.4.1 · · Changelog · This page in the latest edition