java-properties
Visual Studio CodeVS Code Extension is here! Learn more

Java Properties
Translation File Format

Java Properties is a simple text-based file format that is used to store key-value pairs of translations. Learn how to use Java Properties with SimpleLocalize

Upload your translations
No credit card required14-day free trialTracking-free service

Java Properties file example

Java Properties files are simple text files that contain key-value pairs of translations, metadata or configurations. Each line in a Java Properties file represents a single key-value pair, with the key and value separated by an equals sign ( = ). The key is typically a short, descriptive string that identifies the translation, while the value is the translated text. Comments can be added to the file using the hash symbol ( # ). Interpolation is supported by using the {0} syntax to insert dynamic values into the translation. Alternatively, you can use {name} syntax to insert named parameters.

Java Properties example (Polish)
# Polish user.hello=Witaj, {0} login.title=Zaloguj się login.email=Adres e-mail login.password=Hasło
# Polish
user.hello=Witaj, {0}
login.title=Zaloguj się
login.email=Adres e-mail
login.password=Hasło

In most cases, one file contains translations for a single language. For example, you can have a file with translations for English (messages_en.properties) and another file with translations for Polish (messages_pl.properties).

Java Properties example (English)
# English user.hello=Hello, {0} login.title=Log in login.email=Email address login.password=Password
# English
user.hello=Hello, {0}
login.title=Log in
login.email=Email address
login.password=Password

File naming conventions

Java Properties files are typically named using the .properties extension. For example, messages.properties or labels.properties. The name of the file should reflect the purpose of the translations it contains. Since Java properties in most cases contain translations for a specific language, it is a good practice to include the language code in the file name. For example, messages_en.properties or labels_pl.properties.

Java Properties file structure

Property files can be very large, especially in enterprise applications with many modules and components. Splitting translations into multiple files is rarely needed, since *.properties files loaded on application startup are merged into a single ResourceBundle. Unlike frontend applications, where splitting translations into multiple files by namespace or component is a common practice.

Why use *.properties for translations?

Java Properties is a simple and lightweight file format that is easy to work with and understand. It is widely used in JVM based applications (mainly Java, Kotlin, Scala) for storing translations, configuration settings, and other key-value pairs. Thanks to built-in support in Java standard library, it is easy to read and write *.properties files in your application code. For example:

Java Code
Properties messages = new Properties(); messages.load(new FileInputStream("messages_en.properties"));
Properties messages = new Properties();
messages.load(new FileInputStream("messages_en.properties"));

UTF-8 vs ISO-8859-1 encoding

Historically, Java Properties files used the ISO-8859-1 encoding, which supports only a limited set of characters. However, with the introduction of Java 9 in 2017, the default encoding for properties files was changed to UTF-8, which supports a wider range of characters and is more suitable for internationalization. When working with Java Properties files, it is recommended to use the UTF-8 encoding to ensure that your translations are correctly displayed in all languages. SimpleLocalize encodes all Java Properties files in UTF-8 by default.

Java Properties translation encoding

Due to this changes in Java 9, it is recommended to set the encoding explicitly in your application. For example to set UTF-8 encoding in Spring Boot application, you can use the following configuration:

Spring Boot configuration
# application.yml spring: config: encoding: UTF-8
# application.yml
spring:
  config:
    encoding: UTF-8

Properties as XML

Lesser known fact is that *.properties files can also be represented as XML and still be used in Java applications via natively available Properties class. This format is useful when you need to store additional metadata along with the key-value pairs. The XML representation of Java Properties files uses the <properties> element to enclose the key-value pairs, and the<entry> element to represent each key-value pair.

Java Properties as XML
<?xml version="1.0" encoding="utf-8" ?> <properties> <comment>My comment</comment> <entry key="hello-world">Witaj Świecie</entry> <entry key="sign-in">Zaloguj się</entry> <entry key="sign-up">Zarejestruj się</entry> </properties>
<?xml version="1.0" encoding="utf-8" ?>
<properties>
    <comment>My comment</comment>
    <entry key="hello-world">Witaj Świecie</entry>
    <entry key="sign-in">Zaloguj się</entry>
    <entry key="sign-up">Zarejestruj się</entry>
</properties>

Where property files are used?

Property files are commonly used in Java applications to store translations, configuration settings, and other key-value pairs. They are often used for localization, allowing developers to provide translations for different languages without modifying the source code. Files with *.properties extension are used by all JVM based languages like Scala, Groovy, Kotlin. Many frameworks for app development like Spring, Play, Micronaut, Quarkus, etc. use Java Properties for configuration and translations.

Java

Java

Spring Boot

Spring Boot

Play Framework

Play Framework

Micronaut

Micronaut

libGDX

libGDX

Quarkus

Quarkus

Android

Android

Scala

Scala

Kotlin

Kotlin

Groovy

Groovy

Alternatives to Java Properties

Property files are popular choice for translations, and configurations in Java projects thanks to native support in Java standard library and their simplicity and ease of use. If you are looking for alternatives to Java Properties, you may consider using JSON (single language), YAML, Excel, CSV or other file formats that are commonly used for storing translations and configuration settings.

How to keep translation strings in sync?

Managing translations in Java Properties files can be challenging, especially as your project grows and you need to support more and more languages. Updating every property file manually can be time-consuming and error-prone, leading to inconsistencies and missing translations.

SimpleLocalize makes it easy to manage translations in Java properties by providing a centralized platform for storing and updating your translations. You can upload your Java Properties files to our translation editor and manage your translations in one place. With our powerful features like auto-translation, AI actions, bulk actions, and CLI integration, you can keep your translations up-to-date and ensure that your application is localized for all your users.

Meet SimpleLocalize

Your partner in managing translations and localization workflow.
Web-based translation editor helps Java developers keep their *.properties files in sync.

SimpleLocalize translation editor in side-by-side view
  • Auto-translation
  • Screenshots with OCR
  • AI-powered adjustments
  • Built-in Automations
  • Markdown support
  • Variables highlighting
  • Bulk Actions
  • Context-aware translations
  • Acceptance statuses
  • Customizable view
  • Spreadsheet view
  • Text summaries

Auto-translation

Translate your application into multiple languages with just a few clicks. Choose from OpenAI ChatGPT, Google Translate or DeepL translation providers to translate your texts. Adding support for new languages has never been easier.

Learn more about auto-translation
Auto-translation tab in SimpleLocalize

Command-line tool

With SimpleLocalize CLI you can manage your translations from the terminal. It's a powerful tool that helps you to automate the translation process in your project. You can easily synchronize translation files between you local project and SimpleLocalize Translation Editor, start auto-translation or publish changes to the production environment.

CLI documentation
Terminal
# upload strings $ simplelocalize upload # auto-translate strings $ simplelocalize auto-translate # download all translations $ simplelocalize download
# upload strings
$ simplelocalize upload

# auto-translate strings
$ simplelocalize auto-translate

# download all translations
$ simplelocalize download

Public suggestions

Boost collaboration with public suggestions! Public translations offer an excellent opportunity to engage your community by allowing them to contribute to translations. Enable public suggestions, share your project link, and invite users to suggest translations or improvements.

Learn more about public suggestions
SimpleLocalize Public Suggestions
Ready to say
|

Greet your customers
in their native language

Upload your translations
No credit card required