Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

linguatag

linguatag reads BCP 47 language tags. It puts a tag in one canonical form and gives a bare tag its default region and its likely script. It also measures how near two tags are. It picks the best tag from a list of available tags. The package carries all its data: CLDR 49, the IANA Language Subtag Registry, and a dialect tree from orthography2ipa in lineage.json.

Try it in the browser: linguatag on Hugging Face.

from linguatag import closest_lang, lang_distance, likely_script, standardize_lang, with_default_region

print(standardize_lang("en_us"))                       # en-US
print(with_default_region("pt"))                       # pt-PT
print(likely_script("zh-TW"))                          # Hant
print(lang_distance("pt", "pt-BR"))                    # 5
print(closest_lang("en-AU", ["fr-FR", "en-US"]))       # en-US
print(closest_lang("de", ["fr", "it"]))                # None

A bare tag means its motherland: pt is pt-PT and en is en-GB. closest_lang returns the candidate string as you gave it, or None when no candidate is near enough.

Where this fits

Alone: tag normalisation and language matching for any program, with from linguatag import closest_lang. In the stack: the base library for language tags. text2spoken, scriptconv, phoonnx, orthography2ipa and ovos-spec-tools call it to pick a resource for a requested language. It calls no other stack library. Through scriptconv: uv pip install --prerelease=allow "scriptconv[phonemizers]".

Install

uv pip install --prerelease=allow linguatag

linguatag needs Python 3.11 or later and has no dependencies. The langcodes extra is empty. It installs nothing, and it exists so that a pin on linguatag[langcodes] resolves.

Documentation

Page What it covers
Getting started A walk-through of the main calls, with real output
Parsing and normalising tags standardize_lang and parse_tag
Likely subtags and default regions likely_script, default_region, with_default_region and maximize
Matching lang_distance, closest_lang, lang_matches, max_distance, und and private-use tags
Dialects The lects argument for tags with a private-use dialect subtag
Genealogy, place and time parent, ancestors, family and the distance of two languages or two scripts
Data and licence The CLDR 49 and IANA data files, and how to regenerate them
Performance The cost of the first call and of a warm call
Reference The signature and one example of each public name

Start with Getting started, or see the docs index. Contributors read AGENTS.md.

Licence

linguatag is under the Apache License 2.0. The parser and the distance code are a port of langcodes 3.5.1 (MIT). The data files hold CLDR data under the Unicode License v3, and IANA registry data under CC0.

NOTICE and LICENSE-CLDR give the full terms.

Metadata

Release files for linguatag 0.13.5a1

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

Source distribution (sdist)

Source distribution for linguatag 0.13.5a1
File Size Uploaded Provenance Actions
linguatag-0.13.5a1.tar.gz 374.9 kB Without provenance Details for linguatag-0.13.5a1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for linguatag 0.13.5a1
File Interpreter ABI Platform Actions
linguatag-0.13.5a1-py3-none-any.whl Python 3 none any Details for linguatag-0.13.5a1-py3-none-any.whl

Total release size: 731.6 kB

Release files / linguatag-0.13.5a1.tar.gz

Download URL linguatag-0.13.5a1.tar.gz
Size 374.9 kB
Tags Source
SHA-256 checksum
How to use checksums
9a540cd3fe643c7d2c923602b3fddb85a6bd1e185d675401fe75fd942f27a11b
BLAKE2b-256 checksum
How to use checksums
c83bce62392f0da63c9d42abe5a2c0a59e7148ccf11d7d2c467c9c7247dcfa36
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Release files / linguatag-0.13.5a1-py3-none-any.whl

Download URL linguatag-0.13.5a1-py3-none-any.whl
Size 356.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e2ae25f82df8fda9b6954d8aa524c938e22d2b06953010bc8d9f77045a84384b
BLAKE2b-256 checksum
How to use checksums
7deeb7be5c775d00c32639fc6fd34b9e49dba4d0c7fb8e30bbb70bdfcc075d04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.16

Security for linguatag 0.13.5a1

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release
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