]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - shared/models/i18n/i18n.ts
Update target translations
[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
C
4 'en-US': 'English',
5 'fr-FR': 'Français'
989e526a
C
6}
7
74b7c6d4 8const I18N_LOCALE_ALIAS = {
9f164722
C
9 'en': 'en-US',
10 'fr': 'fr-FR'
74b7c6d4
C
11}
12
13export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
14 .concat(Object.keys(I18N_LOCALE_ALIAS))
15
989e526a
C
16export function getDefaultLocale () {
17 return 'en-US'
18}
19
e945b184 20export function isDefaultLocale (locale: string) {
74b7c6d4 21 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
e945b184
C
22}
23
8afc19a6 24const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
989e526a
C
25export function is18nPath (path: string) {
26 return possiblePaths.indexOf(path) !== -1
27}
28
989e526a 29export function is18nLocale (locale: string) {
74b7c6d4
C
30 return POSSIBLE_LOCALES.indexOf(locale) !== -1
31}
32
33export function getCompleteLocale (locale: string) {
34 if (!locale) return locale
35
36 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
37
38 return locale
989e526a
C
39}
40
9f164722
C
41export function getShortLocale (locale: string) {
42 if (locale.indexOf('-') === -1) return locale
43
44 return locale.split('-')[0]
45}
46
989e526a 47export function buildFileLocale (locale: string) {
74b7c6d4 48 const completeLocale = getCompleteLocale(locale)
989e526a 49
74b7c6d4 50 return completeLocale.replace('-', '_')
989e526a 51}