]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/i18n/i18n.ts
Update translations from zanata and add cs and eo
[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',
a55e5579
C
7 'ca-ES': 'català',
8 'cs-CZ': 'čeština',
9 'eo': 'Esperanto'
10e63b68 10 // 'pl-PL': 'polski'
989e526a
C
11}
12
74b7c6d4 13const I18N_LOCALE_ALIAS = {
9f164722 14 'en': 'en-US',
10e63b68
C
15 'fr': 'fr-FR',
16 'eu': 'eu-ES',
a55e5579
C
17 'ca': 'ca-ES',
18 'cs': 'cs-CZ'
10e63b68 19 // 'pl': 'pl-PL'
74b7c6d4
C
20}
21
22export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
23 .concat(Object.keys(I18N_LOCALE_ALIAS))
24
989e526a
C
25export function getDefaultLocale () {
26 return 'en-US'
27}
28
e945b184 29export function isDefaultLocale (locale: string) {
74b7c6d4 30 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
e945b184
C
31}
32
8afc19a6 33const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
989e526a
C
34export function is18nPath (path: string) {
35 return possiblePaths.indexOf(path) !== -1
36}
37
989e526a 38export function is18nLocale (locale: string) {
74b7c6d4
C
39 return POSSIBLE_LOCALES.indexOf(locale) !== -1
40}
41
42export function getCompleteLocale (locale: string) {
43 if (!locale) return locale
44
45 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
46
47 return locale
989e526a
C
48}
49
9f164722
C
50export function getShortLocale (locale: string) {
51 if (locale.indexOf('-') === -1) return locale
52
53 return locale.split('-')[0]
54}
55
989e526a 56export function buildFileLocale (locale: string) {
74b7c6d4 57 const completeLocale = getCompleteLocale(locale)
989e526a 58
74b7c6d4 59 return completeLocale.replace('-', '_')
989e526a 60}