]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/i18n/i18n.ts
Prepare i18n files
[github/Chocobozzz/PeerTube.git] / shared / models / i18n / i18n.ts
1 export const I18N_LOCALES = {
2 'en-US': 'English (US)',
3 fr: 'French'
4 }
5
6 export function getDefaultLocale () {
7 return 'en-US'
8 }
9
10 const possiblePaths = Object.keys(I18N_LOCALES).map(l => '/' + l)
11 export function is18nPath (path: string) {
12 return possiblePaths.indexOf(path) !== -1
13 }
14
15 const possibleLanguages = Object.keys(I18N_LOCALES)
16 export function is18nLocale (locale: string) {
17 return possibleLanguages.indexOf(locale) !== -1
18 }
19
20 // Only use in dev mode, so relax
21 // In production, the locale always match with a I18N_LANGUAGES key
22 export function buildFileLocale (locale: string) {
23 if (!is18nLocale(locale)) {
24 // Some working examples for development purpose
25 if (locale.split('-')[ 0 ] === 'en') return 'en_US'
26 else if (locale === 'fr') return 'fr'
27 }
28
29 return locale.replace('-', '_')
30 }