-
Notifications
You must be signed in to change notification settings - Fork 3k
Expand file tree
/
Copy pathlanguage.ts
More file actions
44 lines (39 loc) · 1.12 KB
/
language.ts
File metadata and controls
44 lines (39 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import { type Language, isLanguage } from "@roo-code/types"
/**
* Language name mapping from ISO codes to full language names.
*/
export const LANGUAGES: Record<Language, string> = {
ca: "Català",
de: "Deutsch",
en: "English",
es: "Español",
fr: "Français",
he: "עברית",
hi: "हिन्दी",
id: "Bahasa Indonesia",
it: "Italiano",
ja: "日本語",
ko: "한국어",
nl: "Nederlands",
pl: "Polski",
"pt-BR": "Português",
ru: "Русский",
tr: "Türkçe",
vi: "Tiếng Việt",
"zh-CN": "简体中文",
"zh-TW": "繁體中文",
}
/**
* Formats a VSCode locale string to ensure the region code is uppercase.
* For example, transforms "en-us" to "en-US" or "fr-ca" to "fr-CA".
*
* @param vscodeLocale - The VSCode locale string to format (e.g., "en-us", "fr-ca")
* @returns The formatted locale string with uppercase region code
*/
export function formatLanguage(vscodeLocale: string): Language {
if (!vscodeLocale) {
return "en"
}
const formattedLocale = vscodeLocale.replace(/-(\w+)$/, (_, region) => `-${region.toUpperCase()}`)
return isLanguage(formattedLocale) ? formattedLocale : "en"
}