ISO 639 Language Library

2.6.3 · active · verified Thu Apr 16

iso639-lang is a fast, comprehensive Python library for working with ISO 639 language codes and information. It provides access to language data across ISO 639-1, -2, and -3 standards. The library is actively maintained with frequent updates, often tied to new releases of the ISO 639-3 tables by SIL, and is currently at version 2.6.3.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to import the `Lang` class, create instances using various ISO 639 identifiers or English names, access language properties, and use the `is_language` validator. It also shows how to find a language from the pre-populated `languages` list.

from iso639 import Lang, languages, is_language

# Get a language by its identifier (ISO 639-1, -2, -3)
lang_en = Lang('en')
print(f"ISO 639-1: {lang_en.part1}, Name: {lang_en.name}")

lang_deu = Lang(part2b='deu') # Using specific part
print(f"ISO 639-2 (bibliographic): {lang_deu.part2b}, Name: {lang_deu.name}")

lang_ara = Lang('ara')
print(f"ISO 639-3: {lang_ara.part3}, Name: {lang_ara.name}, Scope: {lang_ara.scope}, Type: {lang_ara.type}")

# Find a language by its English name (case-insensitive)
lang_french = Lang('French')
print(f"French language: {lang_french.name} ({lang_french.part1})")

# Check if a string is a valid language identifier or name
print(f"'eng' is a language: {is_language('eng')}")
print(f"'invalidcode' is a language: {is_language('invalidcode')}")

# Iterate through all languages
# For performance, avoid loading all languages into memory if not needed
# for lang in languages:
#     if lang.part1 == 'es':
#         print(f"Found Spanish: {lang.name}")
#         break

view raw JSON →