Skip to main content

ISO639 Language Service

Project description

Languager


ISO639 Language Service

This module identifies languages from ISO639-1 and ISO639-3 codes or ISO names and provides a convenient class to access related attributes. It is also possible to lookup codes for languages based on their ISO names. However, the name based lookup will be slower as all language names are compared in lowercase for that.

Basic flows:

  • Code is 2 characters
    • Lookup long code
    • Lookup data
  • Code is 3 characters
    • Lookup data
  • Code is something else
    • Loop all language names to check for match
      • input_language == language_name.lower()
    • Lookup data

This means that that Name based lookup is n-times slower than the other two options. But this really should not make a difference.

Data

The data is taken from iso639-3.sil.org and is stored in the tables folder. Further releases will update these tables.

Code

The code in generator.py generates a single python file that contains all lookup tables and methods.

Language

  • code: The ISO639-3 Code
  • short: ISO639-1 Code if available
  • deprecated: True if the definition is deprecated
  • macro: True if this is in a macrolanguage gropup
  • parent: The parent macrolanguage
  • macros: Any languages belonging to this macrolanguage

Examples

Checking the macrolanguages for Chinese:

from languager import get_language

lang = get_language('zho')
# lang = get_language('zh')
# lang = get_language('Chinese')
# lang = get_language('does not exist', default='zho')

for language in lang.macros:
    print(language)

# czo
# csp
# yue
# cnp
# cmn
# czh
# hak
# nan
# wuu
# cjy
# lzh
# gan
# mnp
# cpx
# hsn
# cdo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

languager-1.0.0.tar.gz (75.8 kB view details)

Uploaded Source

File details

Details for the file languager-1.0.0.tar.gz.

File metadata

  • Download URL: languager-1.0.0.tar.gz
  • Upload date:
  • Size: 75.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.8.9

File hashes

Hashes for languager-1.0.0.tar.gz
Algorithm Hash digest
SHA256 4862a77bc2b67ab4a6aa486c181fadeb715982e73025ed09c0b51ed5f5e4b9b0
MD5 984f2f0c0f0ef0577af3847526e305f9
BLAKE2b-256 f7f9491f564cc64a3ada1242fb1c0e1c3b69897bce3738268a2dd3517c162da0

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page