Java Properties
Java .properties files for translations
.properties files have carried Java translations since
1997: key value lines, # comments, and rules that predate widespread
Unicode, which is why \uXXXX escapes exist. ResourceBundle
and Spring’s MessageSource read them by naming convention, one
file per locale next to the code.
This page covers the three legal separators, the escaping rules, the encoding history, and how plurals travel in a format that has none.
# Checkout screen
checkout.title=Bestellübersicht
checkout.items={count, plural, one {# Artikel} other {# Artikel}}
# Main navigation
menu.home=Startseite
menu.projects=Projekte Cheatsheet
.properties syntax in six rows
key=value, key: value, key value All three separators are legal and all three parse. The exporter writes =. # note or ! note The comment above a key imports as its note and is written back above it on export. Ü Non ASCII is escaped as \uXXXX on export, so the file reads correctly under Java’s old ISO 8859-1 contract and under UTF-8 alike. \= \: and escaped spaces in keys Separator characters inside a key survive because the exporter escapes them; a key like a=b round trips. {count, plural, …} An ICU plural in a value is parsed into CLDR forms translators edit separately, then reassembled on export. Key order
Sorted by name, or kept in the order keys were added. Either way it should stay stable between exports.
auth.signIn=Anmelden
cart.title=Warenkorb
checkout.title=Bestellübersicht checkout.title=Bestellübersicht
cart.title=Warenkorb
auth.signIn=Anmelden Untranslated keys, three spellings
ResourceBundle falls back through the bundle chain when a key is missing, which is usually what you want.
checkout.confirm= # key not exported checkout.confirm=Confirm purchase Conventions
Where .properties lives
src/main/resources/messages_de.properties messages.properties, the fallback locale basename_language_COUNTRY.properties, like messages_de_AT.properties Typical flow: bundles live beside the code, GitHub or GitLab imports new keys on push, and translations return as a merge request per locale file.
Two plural dialects on the JVM
Legacy MessageFormat choice syntax against modern ICU.
files={0,choice,0#no files|1#one file|1<{0} files} files={count, plural, one {# file} other {# files}} Choice format branches on ranges, not CLDR categories, and cannot say Polish or Arabic correctly; it imports as a plain string. The ICU message carries real categories and is parsed into forms.
Plurals
Plurals in .properties
The format has no plural syntax, so ICU messages carry the forms; unlike a plain string, locamorph parses these into separate fields for translators and rebuilds the message on export.
cart.items={count, plural, one {# article} other {# articles}} cart.items={count, plural, one {# item} other {# items}} cart.items={count, plural, one {# artykuł} \
few {# artykuły} many {# artykułów} other {# artykułu}} cart.items={count, plural, zero {لا عناصر} \
one {عنصر واحد} two {عنصران} few {# عناصر} \
many {# عنصرًا} other {# عنصر}} Long values continue across lines with a trailing backslash. The categories come from CLDR: Polish four, Arabic six.
See the same plural in every format locamorph exports.
In locamorph
How locamorph handles .properties
Context survives the trip
The # comment above a key imports as its note and is written back
on export, so the hint a developer left for translators stays in the file.
ICU plurals in plain values
The format has no plural syntax, so plural messages travel as ICU strings that locamorph parses into editable forms and reassembles on export.
Exports without surprises
Stable key order and formatting mean messages_fr.properties diffs
show translation changes, not tooling churn.
Convert
Convert .properties to and from other formats
Conversion is import plus export across the shared key model.
.properties to JSON
A Java backend gaining a JavaScript front end.
- Import
messages_*.properties; comments become notes. - Dotted keys can stay flat or become a tree.
- Export as JSON for your JS i18n library.
.properties to XLIFF
Handing enterprise bundles to a translation agency.
- Import the bundles per locale.
- Notes ride along as XLIFF notes.
- Export XLIFF 1.2 for any CAT tool.
JSON to .properties
Web translations reused by the JVM services.
- Import the JSON locales.
- Trees flatten to dotted keys.
- Export .properties with
\uXXXXescaping applied.
Related
Keep going
YAML
The other side of many Java shops: Rails services and their locale trees.
XLIFF
Hand bundles to an agency in the format their CAT tools expect.
Amazon S3
Publish exported bundles to a bucket your services read at deploy time.
Further reading
- java.util.Properties, the load and store contract
- Spring MessageSource, the format’s biggest consumer
- ICU MessageFormat, the plural syntax carried in values
Bring your messages bundle
Import a .properties file on the free plan and get it back with comments intact and only the translations changed.