|
| 1 | +/** Locales Apple's on-device SpeechTranscriber offers. Unset follows the device language. */ |
| 2 | +export const DICTATION_LANGUAGES = [ |
| 3 | + { locale: "en-US", label: "English (US)" }, |
| 4 | + { locale: "en-GB", label: "English (UK)" }, |
| 5 | + { locale: "en-AU", label: "English (Australia)" }, |
| 6 | + { locale: "en-CA", label: "English (Canada)" }, |
| 7 | + { locale: "en-IN", label: "English (India)" }, |
| 8 | + { locale: "pt-BR", label: "Português (Brasil)" }, |
| 9 | + { locale: "pt-PT", label: "Português (Portugal)" }, |
| 10 | + { locale: "es-ES", label: "Español (España)" }, |
| 11 | + { locale: "es-MX", label: "Español (México)" }, |
| 12 | + { locale: "es-US", label: "Español (EE. UU.)" }, |
| 13 | + { locale: "fr-FR", label: "Français (France)" }, |
| 14 | + { locale: "fr-CA", label: "Français (Canada)" }, |
| 15 | + { locale: "de-DE", label: "Deutsch" }, |
| 16 | + { locale: "it-IT", label: "Italiano" }, |
| 17 | + { locale: "ja-JP", label: "日本語" }, |
| 18 | + { locale: "ko-KR", label: "한국어" }, |
| 19 | + { locale: "zh-CN", label: "中文(普通话)" }, |
| 20 | + { locale: "zh-TW", label: "中文(台灣)" }, |
| 21 | + { locale: "yue-CN", label: "粵語" }, |
| 22 | +] as const; |
| 23 | + |
| 24 | +export type DictationLocale = (typeof DICTATION_LANGUAGES)[number]["locale"]; |
| 25 | + |
| 26 | +const DICTATION_LOCALES: ReadonlySet<string> = new Set( |
| 27 | + DICTATION_LANGUAGES.map((language) => language.locale), |
| 28 | +); |
| 29 | + |
| 30 | +export function isDictationLocale(value: unknown): value is DictationLocale { |
| 31 | + return typeof value === "string" && DICTATION_LOCALES.has(value); |
| 32 | +} |
0 commit comments