ResourceBundle is a module that manages internationalization of string resources.
Slowing down. Last release over 2 years ago, little activity since. Fine for existing code; think twice for a new project.
pip install resourcebundleResourceBundle
ResourceBundle is a package that manages internationalization / localization (i18n / l10n) of string resources.
It is inspired by Java's ResourceBundle and accepts the same format as a Java PropertyResourceBundle.
Note: ResourceBundle is not the pythonic way of internationalization / localization. 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 gettextpofiles.
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 will be raised.