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