python-bcp47
A validating parser for bcp47 language codes
Data taken from IANA http://www.iana.org/assignments/language-subtag-registry/language-subtag-registry
bcp47 spec https://tools.ietf.org/html/bcp47
useful reading: https://www.w3.org/International/articles/language-tags/index.en
extension and private-use tag types are not currently supported
Python example
You can read the languages, extlangs, scripts, variants, regions, grandfathereds, and redundants language tag parts from dicts on the bcp47 object.
They return OrderedDicts containing the IANA database information
>>> from bcp47 import bcp47
>>> list(bcp47["languages"].items())[:2]
[('aa', {'Subtag': 'aa', 'Description': ['Afar'], 'Added': '2005-10-16'}), ('ab', {'Subtag': 'ab', 'Description': ['Abkhazian'], 'Added': '2005-10-16', 'Suppress-Script': 'Cyrl'})]
>>> list(bcp47["regions"].items())[:2]
[('AA', {'Subtag': 'AA', 'Description': ['Private use'], 'Added': '2005-10-16'}), ('AC', {'Subtag': 'AC', 'Description': ['Ascension Island'], 'Added': '2009-07-29'})]
`
You can create a language code tag as follows
>>> tag = bcp47(language="en", region="GB")
>>> tag
<bcp47.code.BCP47Code 'en-GB' />
>>> tag.language
'en'
>>> tag.region
'GB'
>>> str(tag)
'en-GB'
You can also pass a string or list of args to create a tag
>>> bcp47("en-GB")
<bcp47.code.BCP47Code 'en-GB' />
>>> bcp47("en", "GB")
<bcp47.code.BCP47Code 'en-GB' />
Creating a tag with invalid or unrecognized parameters raises an BCP47Exception
>>> tag = bcp47(language="NOTALANGUAGE", region="GB")
Traceback (most recent call last):
...
BCP47Exception: Language 'NOTALANGUAGE' not recognized
>>> tag = bcp47("en-NOTAREGION")
Traceback (most recent call last):
...
BCP47Exception: Unrecognized tag part 'NOTAREGION'
Metadata
Release files for python-bcp47 0.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| python-bcp47-0.0.4.tar.gz | 103.0 kB | Without provenance | Details for python-bcp47-0.0.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_bcp47-0.0.4-py3-none-any.whl | Python 3 | none | any | Details for python_bcp47-0.0.4-py3-none-any.whl |
Total release size: 210.1 kB
Release files / python-bcp47-0.0.4.tar.gz
| Download URL | python-bcp47-0.0.4.tar.gz |
|---|---|
| Size | 103.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
256e618742d85130a2a25db568a9fe6edd8a2d5c9460f38ff9b678f27264a15b
|
|
BLAKE2b-256 checksum How to use checksums |
75ee50b8fcd9d7577311f9ce9632e59442d435fdb26e39c6569b3d6a8a17bb88
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Release files / python_bcp47-0.0.4-py3-none-any.whl
| Download URL | python_bcp47-0.0.4-py3-none-any.whl |
|---|---|
| Size | 107.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c381759702aacd0adf352b004786924028ab8b071a8aeb13756787ce3a8ed477
|
|
BLAKE2b-256 checksum How to use checksums |
6a024635f9e0570868f7f1452c5a97c7cc3328b1cea3d6baac6436c0c5212f60
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.43.0 CPython/3.7.6
|
Security for python-bcp47 0.0.4
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.