IANA-BCP47
iana-bcp47 validates language tags using the grammar from
RFC 5646 and the bundled
IANA Language Subtag Registry.
Validation is local and does not require a network connection.
Features
- Case-insensitive RFC 5646 syntax and ordering validation.
- Registered language, extlang, script, region, and variant subtags.
- Grandfathered and redundant tags.
- Extensions and private-use tags, including IANA private-use ranges.
- Deprecated subtags remain valid and include replacement guidance when IANA provides it.
- Python 3.11 through 3.14.
Extension payloads are checked against the generic RFC 5646 grammar. This package does not
interpret extension-specific standards such as Unicode locale extension semantics. Registry
Prefix values are retained as metadata and guidance; RFC 5646 does not make them a validity
requirement.
Installation
pip install iana-bcp47
Usage
from iana_bcp47 import validate_bcp47
for tag in ["en-US", "EN-us", "zh-Hant-CN", "i-klingon", "x-private"]:
valid, message = validate_bcp47(tag)
print(tag, valid, message)
validate_bcp47(tag) returns (valid, message). Invalid input returns False and an error
message; passing a non-string raises TypeError. The wording of descriptions and errors may
evolve as the IANA registry changes.
The legacy dictionaries remain available from iana_bcp47.bcp47 and from the package root:
from iana_bcp47 import language_codes, region_codes
Data maintenance
The packaged registry date can be read from iana_bcp47._registry.get_registry().file_date.
A scheduled GitHub Actions workflow checks IANA every Monday. When the snapshot changes, it
updates the data, increments the package patch version, runs validation, and opens or refreshes
an automation/iana-registry pull request. A maintainer reviews and merges that PR; a successful
main CI run then publishes the new version through PyPI Trusted Publishing.
To inspect an update locally without modifying files:
python -m pip install -e ".[dev]"
python tools/update_registry.py --dry-run
Run the maintenance checks with:
ruff check .
ruff format --check .
pytest
python -m build
twine check dist/*
check-wheel-contents dist/*.whl
License
MIT. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file iana_bcp47-0.2.0.tar.gz.
File metadata
- Download URL: iana_bcp47-0.2.0.tar.gz
- Upload date:
- Size: 108.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
98765d71ce661dd70e0e7b21ecb1f89859e7187bdd9691a53c8b6b3ea585b409
|
|
| MD5 |
735a1b43b01ef051d73ba4b42459a15c
|
|
| BLAKE2b-256 |
f7e31d874db000ede4cc265f074b11d30a48ed18333991ca8693a5dddbe08451
|
Provenance
The following attestation bundles were made for iana_bcp47-0.2.0.tar.gz:
Publisher:
release.yml on Masterain98/IANA-BCP47
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iana_bcp47-0.2.0.tar.gz -
Subject digest:
98765d71ce661dd70e0e7b21ecb1f89859e7187bdd9691a53c8b6b3ea585b409 - Sigstore transparency entry: 2434485300
- Sigstore integration time:
-
Permalink:
Masterain98/IANA-BCP47@14f90e91241c0dba591636612f2b4b791e73a08e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Masterain98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14f90e91241c0dba591636612f2b4b791e73a08e -
Trigger Event:
workflow_run
-
Statement type:
File details
Details for the file iana_bcp47-0.2.0-py3-none-any.whl.
File metadata
- Download URL: iana_bcp47-0.2.0-py3-none-any.whl
- Upload date:
- Size: 112.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
56e552fb9d696e1e5f3355da2d6b878dd885efdb2f79e6a90e007c943554c7d3
|
|
| MD5 |
5ca4bf120bd44c4d344a0303d447c880
|
|
| BLAKE2b-256 |
a45358218ebf0b184c010c54ca97ce08ab76470ac0e6eb8ff800f8b0b18d4082
|
Provenance
The following attestation bundles were made for iana_bcp47-0.2.0-py3-none-any.whl:
Publisher:
release.yml on Masterain98/IANA-BCP47
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
iana_bcp47-0.2.0-py3-none-any.whl -
Subject digest:
56e552fb9d696e1e5f3355da2d6b878dd885efdb2f79e6a90e007c943554c7d3 - Sigstore transparency entry: 2434485552
- Sigstore integration time:
-
Permalink:
Masterain98/IANA-BCP47@14f90e91241c0dba591636612f2b4b791e73a08e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Masterain98
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@14f90e91241c0dba591636612f2b4b791e73a08e -
Trigger Event:
workflow_run
-
Statement type: