]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/i18n/i18n.ts
Fix transcoding
[github/Chocobozzz/PeerTube.git] / shared / models / i18n / i18n.ts
CommitLineData
74b7c6d4
C
1export const LOCALE_FILES = [ 'player', 'server' ]
2
244b4ae3 3export const I18N_LOCALES: any = {
8afc19a6 4 'en-US': 'English',
10e63b68 5 'fr-FR': 'Français',
7f768064
Q
6 'eu-ES': 'Euskara',
7 'ca-ES': 'Català',
8 'cs-CZ': 'Čeština',
fb9e6cb0
C
9 'eo': 'Esperanto',
10 'de-DE': 'Deutsch',
7f768064
Q
11 'es-ES': 'Español',
12 'oc': 'Occitan',
1e45c78f 13 'zh-Hant-TW': '繁體中文(台灣)',
a9155ee6 14 'pt-BR': 'Português (Brasil)',
1e45c78f 15 'sv-SE': 'svenska',
7f768064 16 // 'pl-PL': 'Polski'
1e45c78f 17 'zh-Hans-CN': '简体中文(中国)'
989e526a
C
18}
19
244b4ae3 20const I18N_LOCALE_ALIAS: any = {
9f164722 21 'en': 'en-US',
10e63b68
C
22 'fr': 'fr-FR',
23 'eu': 'eu-ES',
a55e5579 24 'ca': 'ca-ES',
fb9e6cb0
C
25 'cs': 'cs-CZ',
26 'de': 'de-DE',
a9155ee6
C
27 'es': 'es-ES',
28 'pt': 'pt-BR',
29 'sv': 'sv-SE'
10e63b68 30 // 'pl': 'pl-PL'
74b7c6d4
C
31}
32
33export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
34 .concat(Object.keys(I18N_LOCALE_ALIAS))
35
989e526a
C
36export function getDefaultLocale () {
37 return 'en-US'
38}
39
e945b184 40export function isDefaultLocale (locale: string) {
74b7c6d4 41 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
e945b184
C
42}
43
3dfa8494
C
44export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
45 return translations && translations[str] ? translations[str] : str
46}
47
8afc19a6 48const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
989e526a
C
49export function is18nPath (path: string) {
50 return possiblePaths.indexOf(path) !== -1
51}
52
989e526a 53export function is18nLocale (locale: string) {
74b7c6d4
C
54 return POSSIBLE_LOCALES.indexOf(locale) !== -1
55}
56
57export function getCompleteLocale (locale: string) {
58 if (!locale) return locale
59
60 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
61
62 return locale
989e526a
C
63}
64
9f164722
C
65export function getShortLocale (locale: string) {
66 if (locale.indexOf('-') === -1) return locale
67
68 return locale.split('-')[0]
69}
70
989e526a 71export function buildFileLocale (locale: string) {
74b7c6d4 72 const completeLocale = getCompleteLocale(locale)
989e526a 73
fb9e6cb0 74 return completeLocale.replace(/-/g, '_')
989e526a 75}