]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/i18n/i18n.ts
[#766] Fix the change of speed when quality changes
[github/Chocobozzz/PeerTube.git] / shared / models / i18n / i18n.ts
1 export const LOCALE_FILES = [ 'player', 'server' ]
2
3 export const I18N_LOCALES = {
4 'en-US': 'English',
5 'fr-FR': 'Français',
6 'eu-ES': 'euskara',
7 'ca-ES': 'catalĂ '
8 // 'pl-PL': 'polski'
9 }
10
11 const I18N_LOCALE_ALIAS = {
12 'en': 'en-US',
13 'fr': 'fr-FR',
14 'eu': 'eu-ES',
15 'ca': 'ca-ES'
16 // 'pl': 'pl-PL'
17 }
18
19 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
20 .concat(Object.keys(I18N_LOCALE_ALIAS))
21
22 export function getDefaultLocale () {
23 return 'en-US'
24 }
25
26 export function isDefaultLocale (locale: string) {
27 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
28 }
29
30 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
31 export function is18nPath (path: string) {
32 return possiblePaths.indexOf(path) !== -1
33 }
34
35 export function is18nLocale (locale: string) {
36 return POSSIBLE_LOCALES.indexOf(locale) !== -1
37 }
38
39 export function getCompleteLocale (locale: string) {
40 if (!locale) return locale
41
42 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
43
44 return locale
45 }
46
47 export function getShortLocale (locale: string) {
48 if (locale.indexOf('-') === -1) return locale
49
50 return locale.split('-')[0]
51 }
52
53 export function buildFileLocale (locale: string) {
54 const completeLocale = getCompleteLocale(locale)
55
56 return completeLocale.replace('-', '_')
57 }