{"id":24523,"library":"resourcebundle","title":"ResourceBundle","description":"ResourceBundle is an i18n module for managing string resources in Python, supporting .properties, JSON, and YAML formats. Current version is 2.2.0, requiring Python >=3.5. It follows Java ResourceBundle patterns with locale fallback.","status":"active","version":"2.2.0","language":"python","source_language":"en","source_url":"https://github.com/felix-zenk/ResourceBundle","tags":["i18n","localization","resource-bundle","properties","json","yaml"],"install":[{"cmd":"pip install resourcebundle","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"note":"","wrong":"","symbol":"ResourceBundle","correct":"from resourcebundle import ResourceBundle"},{"note":"","wrong":"","symbol":"ResourceBundleError","correct":"from resourcebundle import ResourceBundleError"}],"quickstart":{"code":"from resourcebundle import ResourceBundle\nimport os\n# Create a bundle with base name 'messages' in current directory\nbundle = ResourceBundle('messages', base_path='.', locale='en')\nprint(bundle.get('greeting', default='Hello'))\n# Output: Hello (or translated value if 'messages_en.properties' exists)","lang":"python","description":"Create a ResourceBundle with base name 'messages', locale 'en', and get a string 'greeting'."},"warnings":[{"fix":"Check the changelog and update your code to use the new API (e.g., ResourceBundle constructor arguments changed).","message":"v2.0.0 introduced breaking changes to the API and file format support. Code written for v1.x may require migration.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use JSON or YAML format instead of XML.","message":"Built-in XML support is deprecated and may be removed in a future release.","severity":"deprecated","affected_versions":">=2.0.0"},{"fix":"Upgrade to v2.0.1 or later, or ensure the base name exists.","message":"ResourceBundle silently accepts non-existent base names (until v2.0.1). In v2.0.1+, an error is raised if no files found.","severity":"gotcha","affected_versions":"<2.0.1"},{"fix":"Upgrade to v2.0.5+ if you use multi-line property values.","message":"Line continuations in .properties files (using backslash) are only supported from v2.0.5 onward.","severity":"gotcha","affected_versions":"<2.0.5"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use bundle.get(key, default='default_value') to avoid None.","cause":"ResourceBundle returns None when a key is not found and no default is provided.","error":"AttributeError: 'NoneType' object has no attribute 'get'"},{"fix":"Verify the base name spelling and that the file exists in the base_path directory.","cause":"The base name does not correspond to any existing resource file in the specified path.","error":"resourcebundle.exceptions.ResourceBundleError: No resource file found for base name 'messages'"},{"fix":"Run 'pip install resourcebundle' to install the package.","cause":"Missing or incorrect installation of the resourcebundle package.","error":"ImportError: cannot import name 'ResourceBundle' from 'resourcebundle'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}