Skip to main content

ResourceBundle

PyPI-Versions PyPI version License

ResourceBundle is a module that manages internationalization of string resources. It is inspired by javas ResourceBundle and accepts the same format as a java PropertyResourceBundle.

Note: ResourceBundle is not the python way of doing internationalization. This package is only intended to be used if you absolutely have to work with ResourceBundle files or need a quick working way when porting from java.

For information on how to do internationalization in python, see the official documentation. You can use the ResourceBundle.Converter.to_gettext() method to convert your ResourceBundle files to gettext po files.


Installation

The ResourceBundle module can be downloaded from PyPI:

# linux / macOS
$  python3 -m pip install ResourceBundle

# windows
>  py -m pip install ResourceBundle

Usage

Assuming you come from java, you are probably familiar with the ResourceBundle file format. If not,you can read about it here.

Get a ResourceBundle instance is by using ResourceBundle.get_bundle(name, locale).

import ResourceBundle

bundle = ResourceBundle.get_bundle("Strings", "en")

# It is now possible to get a resource with the get() method
bundle.get("key")

If the key could not be found in the ResourceBundle the parent ResourceBundles will be searched until a matching key was found. If the key is not present in any of its parents a ResourceBundle.exceptions.NotInResourceBundleError will be raised.


gettext

The ResourceBundle module can convert ResourceBundle files to gettext pot / po files. This can be done by using the ResourceBundle.Converter.to_gettext() function.

from ResourceBundle import Converter

# convert all .properties files in the current directory to .po files
Converter.to_gettext(".", ".")

Note however that this step is obsolete if you are using gettext properly as this will include automatically extracting strings from your source code. The function is only intended as a head start to keep existing translations.

Metadata

Release files for ResourceBundle 2.1.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 ResourceBundle 2.1.0
File Size Uploaded Provenance Actions
ResourceBundle-2.1.0.tar.gz 6.9 kB Without provenance Details for ResourceBundle-2.1.0.tar.gz

Built distribution (wheel)

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

Total release size: 14.2 kB

Release files / ResourceBundle-2.1.0.tar.gz

Download URL ResourceBundle-2.1.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
32bcbfd8af9c0331c19e6851db58774bf84c54433c1d2378fc9a4cc4cbb3b00c
BLAKE2b-256 checksum
How to use checksums
b035fa1e379b8ea46b5afb57d28b826515e6068a0c7bfbd64b90d8a6173711bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Release files / ResourceBundle-2.1.0-py3-none-any.whl

Download URL ResourceBundle-2.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
024411e031f18411a4539888dfe5f9f9b0be3a31c8c9b83cf1f367e1c801cfbc
BLAKE2b-256 checksum
How to use checksums
9f1a7d165fe383691b2c4573b11b971e0fbe250d2ba21050e5e6ef689fb780a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.11.3

Security for ResourceBundle 2.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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