Skip to main content

get_supported_language_variant

Return the language code that's listed in supported languages, possibly selecting a more generic variant. Raise LookupError if nothing is found.

def get_supported_language_variant(
lang_code: string,
strict: boolean = False
) - > string

Return the language code that's listed in supported languages, possibly selecting a more generic variant. Raise LookupError if nothing is found.

Parameters

NameTypeDescription
lang_codestringThe IETF language tag (e.g., 'en-US' or 'zh-hant-tw') to be validated against supported project languages.
strictboolean = FalseIf False, the function will attempt to find any country-specific variant if the exact code or its generic base is not supported.

Returns

TypeDescription
stringThe matching language code from the supported languages list, which may be the original code, a generic variant, or a country-specific fallback.