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