diff options
Diffstat (limited to 'shared/models/i18n')
-rw-r--r-- | shared/models/i18n/i18n.ts | 105 | ||||
-rw-r--r-- | shared/models/i18n/index.ts | 1 |
2 files changed, 0 insertions, 106 deletions
diff --git a/shared/models/i18n/i18n.ts b/shared/models/i18n/i18n.ts deleted file mode 100644 index 9ad0f456d..000000000 --- a/shared/models/i18n/i18n.ts +++ /dev/null | |||
@@ -1,105 +0,0 @@ | |||
1 | export const LOCALE_FILES = [ 'player', 'server' ] | ||
2 | |||
3 | export const I18N_LOCALES = { | ||
4 | // Always first to avoid issues when using express acceptLanguages function when no accept language header is set | ||
5 | 'en-US': 'English', | ||
6 | |||
7 | 'ar': 'العربية', | ||
8 | 'ca-ES': 'Català', | ||
9 | 'cs-CZ': 'Čeština', | ||
10 | 'de-DE': 'Deutsch', | ||
11 | 'el-GR': 'ελληνικά', | ||
12 | 'eo': 'Esperanto', | ||
13 | 'es-ES': 'Español', | ||
14 | 'eu-ES': 'Euskara', | ||
15 | 'fi-FI': 'suomi', | ||
16 | 'fr-FR': 'Français', | ||
17 | 'gd': 'Gàidhlig', | ||
18 | 'hu-HU': 'magyar', | ||
19 | 'it-IT': 'Italiano', | ||
20 | 'ja-JP': '日本語', | ||
21 | 'kab': 'Taqbaylit', | ||
22 | 'nl-NL': 'Nederlands', | ||
23 | 'oc': 'Occitan', | ||
24 | 'pl-PL': 'Polski', | ||
25 | 'pt-BR': 'Português (Brasil)', | ||
26 | 'pt-PT': 'Português (Portugal)', | ||
27 | 'ru-RU': 'русский', | ||
28 | 'sv-SE': 'svenska', | ||
29 | 'th-TH': 'ไทย', | ||
30 | 'vi-VN': 'Tiếng Việt', | ||
31 | 'zh-Hans-CN': '简体中文(中国)', | ||
32 | 'zh-Hant-TW': '繁體中文(台灣)' | ||
33 | } | ||
34 | |||
35 | const I18N_LOCALE_ALIAS = { | ||
36 | 'ar-001': 'ar', | ||
37 | 'ca': 'ca-ES', | ||
38 | 'cs': 'cs-CZ', | ||
39 | 'de': 'de-DE', | ||
40 | 'el': 'el-GR', | ||
41 | 'en': 'en-US', | ||
42 | 'es': 'es-ES', | ||
43 | 'eu': 'eu-ES', | ||
44 | 'fi': 'fi-FI', | ||
45 | 'fr': 'fr-FR', | ||
46 | 'hu': 'hu-HU', | ||
47 | 'it': 'it-IT', | ||
48 | 'ja': 'ja-JP', | ||
49 | 'nl': 'nl-NL', | ||
50 | 'pl': 'pl-PL', | ||
51 | 'pt': 'pt-BR', | ||
52 | 'ru': 'ru-RU', | ||
53 | 'sv': 'sv-SE', | ||
54 | 'th': 'th-TH', | ||
55 | 'vi': 'vi-VN', | ||
56 | 'zh-CN': 'zh-Hans-CN', | ||
57 | 'zh-Hans': 'zh-Hans-CN', | ||
58 | 'zh-Hant': 'zh-Hant-TW', | ||
59 | 'zh-TW': 'zh-Hant-TW', | ||
60 | 'zh': 'zh-Hans-CN' | ||
61 | } | ||
62 | |||
63 | export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES) | ||
64 | .concat(Object.keys(I18N_LOCALE_ALIAS)) | ||
65 | |||
66 | export function getDefaultLocale () { | ||
67 | return 'en-US' | ||
68 | } | ||
69 | |||
70 | export function isDefaultLocale (locale: string) { | ||
71 | return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale()) | ||
72 | } | ||
73 | |||
74 | export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) { | ||
75 | // FIXME: remove disable rule when the client is upgraded to typescript 3.7 | ||
76 | // eslint-disable-next-line | ||
77 | return translations && translations[str] ? translations[str] : str | ||
78 | } | ||
79 | |||
80 | const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l) | ||
81 | export function is18nPath (path: string) { | ||
82 | return possiblePaths.includes(path) | ||
83 | } | ||
84 | |||
85 | export function is18nLocale (locale: string) { | ||
86 | return POSSIBLE_LOCALES.includes(locale) | ||
87 | } | ||
88 | |||
89 | export function getCompleteLocale (locale: string) { | ||
90 | if (!locale) return locale | ||
91 | |||
92 | if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale] | ||
93 | |||
94 | return locale | ||
95 | } | ||
96 | |||
97 | export function getShortLocale (locale: string) { | ||
98 | if (locale.includes('-') === false) return locale | ||
99 | |||
100 | return locale.split('-')[0] | ||
101 | } | ||
102 | |||
103 | export function buildFileLocale (locale: string) { | ||
104 | return getCompleteLocale(locale) | ||
105 | } | ||
diff --git a/shared/models/i18n/index.ts b/shared/models/i18n/index.ts deleted file mode 100644 index 8f7cbe2c7..000000000 --- a/shared/models/i18n/index.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export * from './i18n' | ||