Skip to main content

i18ntools

Translate i18n Java properties files to desired language(s).

Description • Installation • Usage • License

Description

i18ntools is a collection of Python scripts to help translate your Java properties internationalization files using Azure Cognitive Services Translator.

What does each script do?

  • translate.py translates an entire i18n Java properties file into a new i18n Java properties file of a different language.
  • translate_missing.py translates the messages in an i18n Java properties file that are missing from an i18n Java properties file of a different language. The missing messages will be appended at the end of the output file unless the --sort option is used. Note: using the --sort option will delete comments in the output file that are not present in the input file.
  • parse_i18n_file.py reads an i18n Java properties file and returns the data as a dictionary.
  • sort_i18n_file.py sorts the messages in a given i18n Java properties file so that they are in the same order as the messages in a different i18n Java properties file. Using this script will delete comments in the sorted output file that are not present in the input file.

Installation

You can install the i18ntools package using pip:

python -m pip install i18ntools

i18ntools officially supports Python 3.11+.

It is recommended to install i18ntools in a virtual environment rather than being installed globally:

python -m venv i18n_env
source i18n_env/bin/activate
python -m pip install i18ntools

When this package is installed, CLI executables of the scripts will be installed on the path of your virtual environment.

translate --help
translate-missing --help
parse-i18n-file --help
sort-i18n-file --help

Usage

Before using translate.py or translate_missing.py, your Azure API secret key must be set in an environment variable named TRANSLATOR_API_SUBSCRIPTION_KEY.

export TRANSLATOR_API_SUBSCRIPTION_KEY=<your_key>

You can accomplish this on Windows with the following command:

C:\>set TRANSLATOR_API_SUBSCRIPTION_KEY=<your_key>

Suppose you have the following in a file named /home/docs/example.properties:

default.invalid.min.message=Property [{0}] of class [{1}] with value [{2}] is less than minimum value [{3}]

# Track 4 on Expert In A Dying Field
TheBeths.YourSide.lyrics=I want to see you knocking at the door. \
    I wanna leave you out there waiting in the downpour. \
    Singing that you’re sorry, dripping on the hall floor.
instructor.submitWithCustomTime.customSubmitTS.missing.error=The customSubmitTS parameter is missing. \
    It must be present and of type Date.

# SessionItem.itemID is the first parameter
instructorService.removeSession.success={0} session removed.

handshake.register.suspended.error=The trial period has ended for your account \
    and you can no longer use the application.
handshake.register.disabledException.error=Instructor is disabled

When you run:

translate -i=/home/docs/example.properties -t=es

Then a new file named /home/docs/example_es.properties will be saved and contain Spanish translations of the input file, with the comments preserved:

default.invalid.min.message=La propiedad [{0}] de la clase [{1}] con valor [{2}] es menor que el valor mínimo [{3}]

# Track 4 on Expert In A Dying Field
TheBeths.YourSide.lyrics=Quiero verte llamando a la puerta. \
    Quiero dejarte ahí afuera esperando bajo el aguacero. \
    Cantando que lo sientes, goteando en el piso del pasillo.
instructor.submitWithCustomTime.customSubmitTS.missing.error=Falta el parámetro customSubmitTS. \
    Debe estar presente y ser de tipo Fecha.

# SessionItem.itemID is the first parameter
instructorService.removeSession.success={0} sesión eliminada.

handshake.register.suspended.error=El período de prueba ha finalizado para su cuenta \
    y ya no puede usar la aplicación.
handshake.register.disabledException.error=El instructor está deshabilitado

Options

These are the options for translate.py. Details about how to use each file can be found by running it with the --help flag.

Key Alias Description Default
--help -h All available options. /
--region -r Region of the Azure translator resource. eastus2
--input_file [required] -i Path to a .properties file to translate. /
--from_lang -f From which language you want to translate. en
--to [required] -t To which language you want to translate. For example, use de to translate to German. /
--output_file -o Path where the translated .properties file will be saved. Overwrites any existing file. input_file with the output language appended to the filename; i.e., messages.properties would become messages_de.properties.

Translate multiple files

If you want to tranlsate multiple entire files, you can create a Python file that imports the i18ntools.translate module and calls translate_file:

from i18ntools.translate import translate_file


files = [
    "app/Admin/i18n/messageBundle.properties",
    "app/Device/crud/i18n/messageBundle.properties",
    "app/Login/i18n/messageBundle.properties",
]

output_lang = "es"

for input_file in files:
    translate_file(input_file, output_lang)

If you want to tranlsate missing messages from multiple files, you can create a Python file that imports the i18ntools.translate_missing module and calls translate_missing_messages:

from i18ntools.translate_missing import translate_missing_messages


files = [
    "app/Admin/i18n/messageBundle.properties",
    "app/Device/crud/i18n/messageBundle.properties",
    "app/Login/i18n/messageBundle.properties",
]

for input_file in files:
    # This assumes the following files exist:
    # app/Admin/i18n/messageBundle_es.properties
    # app/Device/crud/i18n/messageBundle_es.properties
    # app/Login/i18n/messageBundle_es.properties
    translate_missing_messages(input_file, output_lang="es", sort_file=True)

Obtaining API keys

  • Azure
    • Follow the instructions here.

License

Contribute

Contributions are more than welcome. Please see the contribution instructions.

Metadata

Release files for i18ntools 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for i18ntools 0.3.0
File Size Uploaded Provenance Actions
i18ntools-0.3.0.tar.gz 16.4 kB With provenance Details for i18ntools-0.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for i18ntools 0.3.0
File Interpreter ABI Platform Actions
i18ntools-0.3.0-py3-none-any.whl Python 3 none any Details for i18ntools-0.3.0-py3-none-any.whl

Total release size: 30.7 kB

Release files / i18ntools-0.3.0.tar.gz

Download URL i18ntools-0.3.0.tar.gz
Size 16.4 kB
Tags Source
SHA-256 checksum
How to use checksums
30ea7aa6076baffbe814715146db52b0fba7e8d20c5c22f00a3f42317adafe3b
BLAKE2b-256 checksum
How to use checksums
ec139e08ef5ae390a36721e18fc4683686991f0e434e304d92efaf9ec060b302
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Release files / i18ntools-0.3.0-py3-none-any.whl

Download URL i18ntools-0.3.0-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13c83c44c8b3ce7a95aac785cc04c977f1ba49211346fca80c6dcb331b19ddb7
BLAKE2b-256 checksum
How to use checksums
7aa297132fd5088a8ed16664dc859194b4dd97b6a242fd4f105950bbcb3794a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

Security for i18ntools 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for i18ntools-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 20, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page