Skip to main content

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.

Metadata

Release files for iana-bcp47 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for iana-bcp47 0.2.1
File Size Uploaded
iana_bcp47-0.2.1.tar.gz 108.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for iana-bcp47 0.2.1
File Interpreter ABI Platform
iana_bcp47-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 221.2 kB

Release files / iana_bcp47-0.2.1.tar.gz

Download URL iana_bcp47-0.2.1.tar.gz
Size 108.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a1cb25ddf48ef7432d79d00762d6b2386825a04cca7add46be720f4d410f5f78
BLAKE2b-256 checksum
How to use checksums
55c18e1ddd38050da528a2ccff353e5711de7f5b2244a1ce53608b3acc061f63
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release files / iana_bcp47-0.2.1-py3-none-any.whl

Download URL iana_bcp47-0.2.1-py3-none-any.whl
Size 112.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f02d8a672c5b903b8fb6c2b5d7ee4be1242a8f9cb78ce5dcdc32c4270b3e770
BLAKE2b-256 checksum
How to use checksums
dcb09b20f6aea5cabb066be724ab5feffc08772c3200b9e360faedd56cef2348
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 21, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

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