Registry / serialization / babelfish

babelfish

JSON →
library0.6.1pypypi✓ verified 85d ago

A Python library for working with countries and languages, providing enums, conversion, and lookup utilities. Current version is 0.6.1 (released 2023-11-26), with a slow release cadence (~yearly). Supports Python >=3.8.

pip install babelfish
INSTALL
IMPORT
SIG · BABELFISH
B
babelfish
serializationpythonv0.6.1
Install
1.7s avg
Import
161ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.6.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.168s · 18.1MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.7s · import 0.154s · 19MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Country
from babelfish import Country
Language
from babelfish import Language

Basic usage: create Country and Language objects from codes and access properties.

from babelfish import Country, Language # Look up by code c = Country('US') print(c.name) # United States l = Language('eng') print(l.name) # English # From alpha3 code (three-letter) print(Country.fromalpha3('USA')) # Country('US')
Debug
Known issues
gotchaCountry and Language objects use enums internally but are not directly mutable after creation. Trying to set attributes may raise AttributeError.
fix
Create a new object if you need a different code.
affects: all
deprecatedpkg_resources usage was removed in 0.6.0. If you rely on package resources via babelfish, you may need to adjust.
fix
Use importlib.resources as replacement if needed.
affects: >=0.6.0
gotchaCountry codes are case-sensitive internally. 'us' is not the same as 'US' for direct instantiation; use upper-case strings.
fix
Always use uppercase codes (e.g., 'US', 'GB').
affects: all
Errors
Common errors & fixes
ImportError: cannot import name 'Country' from 'babelfish'
Partial or old installation, or wrong import path.
fix
Reinstall with: pip install --upgrade babelfish. The correct import is: from babelfish import Country
AttributeError: module 'babelfish' has no attribute 'Country'
File named babelfish.py in current directory shadows the library.
fix
Rename your local file (e.g., babelfish_example.py) and remove any cached .pyc files.
Unknown code: us
Country constructor expects uppercase ISO 3166-1 alpha-2 codes.
fix
Use uppercase: Country('US')
Upgrade
Version history
0.6.1latest on PyPI · released May 9, 2024
Audit
Dependencies

No dependency data recorded yet.

Agent activity
27 hits · last 30 days
node
22
Amazon
1
OpenAI (training)
1
Resources
babelfish — pip install babelfish · libregistry