Repository navigation
Expand file tree
/
Copy pathlanguage.ts
More file actions
63 lines (54 loc) · 1.48 KB
/
Copy pathlanguage.ts
File metadata and controls
63 lines (54 loc) · 1.48 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import type { Locale } from './locale'
import type { DocLanguage } from '@/types/doc-paths'
import data from './languages'
import { supportedLocales } from './locale'
export type I18nText = Record<(typeof LanguagesSupported)[number], string>
export const languages = data.languages
export const LanguagesSupported: Locale[] = supportedLocales
const DOC_LANGUAGE: Record<string, DocLanguage | undefined> = {
'zh-Hans': 'zh',
'ja-JP': 'ja',
'en-US': 'en',
}
export type AccessControlTemplateLanguage = 'zh' | 'ja' | 'en'
const ACCESS_CONTROL_TEMPLATE_LANGUAGE: Record<string, AccessControlTemplateLanguage> = {
'zh-Hans': 'zh',
'ja-JP': 'ja',
'en-US': 'en',
}
export const localeMap: Record<Locale | 'en_US' | 'zh_Hans' | 'ja_JP', string> = {
'en-US': 'en',
en_US: 'en',
'zh-Hans': 'zh-cn',
zh_Hans: 'zh-cn',
'zh-Hant': 'zh-tw',
'pt-BR': 'pt-br',
'es-ES': 'es',
'fr-FR': 'fr',
'de-DE': 'de',
'ja-JP': 'ja',
ja_JP: 'ja',
'ko-KR': 'ko',
'lo-LA': 'lo',
'ru-RU': 'ru',
'it-IT': 'it',
'th-TH': 'th',
'id-ID': 'id',
'nl-NL': 'nl',
'uk-UA': 'uk',
'vi-VN': 'vi',
'ro-RO': 'ro',
'pl-PL': 'pl',
'hi-IN': 'hi',
'tr-TR': 'tr',
'fa-IR': 'fa',
'sl-SI': 'sl',
'ar-TN': 'ar',
'az-AZ': 'az',
}
export const getDocLanguage = (locale: string): DocLanguage => {
return DOC_LANGUAGE[locale] || 'en'
}
export const getAccessControlTemplateLanguage = (locale: string): AccessControlTemplateLanguage => {
return ACCESS_CONTROL_TEMPLATE_LANGUAGE[locale] || 'en'
}