{"library":"langcodes","code":"from langcodes import Language, standardize_tag, closest_match\n\n# Parse a language tag\nenglish_us = Language.get('en-US')\nprint(f\"Parsed 'en-US': language={english_us.language}, script={english_us.script}, territory={english_us.territory}\")\n\n# Normalize a language tag\nnormalized_tag = standardize_tag('zh-CN')\nprint(f\"Normalized 'zh-CN': {normalized_tag}\")\n\n# Compare languages using distance (lower is better match)\nfrench = Language.get('fr')\ncanadian_french = Language.get('fr-CA')\nprint(f\"Distance between 'fr' and 'fr-CA': {french.distance(canadian_french)}\")\n\n# Find the closest match from a list of supported languages\ndesired = 'en-GB'\nsupported = ['en-US', 'en-AU', 'fr-CA']\nclosest = closest_match(desired, supported)\nprint(f\"Closest match for '{desired}' in {supported}: {closest}\")\n\n# Get display names (requires 'langcodes[data]' to be installed)\ntry:\n    spanish_name_in_english = Language.get('es').display_name('en')\n    print(f\"Name of 'es' in English: {spanish_name_in_english}\")\nexcept ImportError:\n    print(\"Install 'langcodes[data]' (e.g., pip install langcodes[data]) for language names and statistics.\")","lang":"python","description":"Demonstrates parsing, normalizing, comparing language tags using distance, finding closest matches, and retrieving display names (with an optional dependency).","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}