/* * Copyright (C) 2026 - present Instructure, Inc. * * This file is part of Canvas Studio. * * Canvas Studio is free software: you can redistribute it and/or modify it under * the terms of the GNU Affero General Public License as published by the Free * Software Foundation, version 3 of the License. * * Canvas Studio is distributed in the hope that it will be useful, but WITHOUT ANY * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR * A PARTICULAR PURPOSE. See the GNU Affero General Public License for more * details. * * You should have received a copy of the GNU Affero General Public License along * with this program. If not, see . */ import {languageDisplayName} from './languageDisplayName' const asrSupportedLanguageIds = [ 'ar', 'zh', 'cs', 'da', 'nl', 'en', 'fr', 'de', 'it', 'ja', 'ko', 'lv', 'lt', 'no', 'pl', 'pt', 'ru', 'es', 'sv', 'tr', ] const asrSupportedLanguages = asrSupportedLanguageIds.map(id => ({ id, get label() { return languageDisplayName(id) }, })) function sortedAsrLanguageList(userLocale: string) { const ul = userLocale.replace('_', '-') const langlist = asrSupportedLanguages.sort((a, b) => { if (a.id === ul) { return -1 } if (b.id === ul) { return 1 } return a.label.localeCompare(b.label, ul) }) return langlist } function asrLanguageForLocale(locale: string) { return asrSupportedLanguages.find(lang => lang.id === locale)?.label || locale } export {sortedAsrLanguageList, asrLanguageForLocale}