function whisper_language_to_code(language) {
    language = language.toLowerCase();

    // Map to code from user-friendly name (e.g., "english" -> "en")
    let language_code = WHISPER_TO_LANGUAGE_CODE_MAPPING.get(language);

    if (language_code === undefined) {
        // User provided something that is not a language name

        // Perhaps the user passed the special token itself
        const language_special_token = language.match(/^<\|([a-z]{2})\|>$/);
        if (language_special_token) {
            language = language_special_token[1];
        }

        if (WHISPER_LANGUAGE_MAPPING.has(language)) {
            // User provided the language code directly (e.g., "en")
            language_code = language;

        } else {
            // User provided something that is not a language code or name
            const is_language_code = language.length === 2;
            const langs = is_language_code ? WHISPER_LANGUAGE_MAPPING.keys() : WHISPER_LANGUAGE_MAPPING.values();

            throw new Error(`Language "${language}" is not supported. Must be one of: ${JSON.stringify(Array.from(langs))}`);
        }
    }
    return language_code;
}
@param {string} language The language name or code
@returns {string} The language code