Skip to main content

get_supported_language_variant

Returns a supported language-variant code from the provided language code, optionally using strict matching to ensure the variant is explicitly defined in the translation system.

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

Returns the language code that is supported by the system, potentially falling back to a more generic variant if the specific one is not available.

Parameters

NameTypeDescription
lang_codestringThe language code or locale string to check for support.
strictboolean = FalseIf True, only an exact match for the language code is accepted; if False, the function allows falling back to a generic variant.

Returns

TypeDescription
stringThe supported language code variant (e.g., 'en' if 'en-us' is not supported), or raises a LookupError if no match is found.