1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
12 'nl-NL': 'Nederlands',
15 'zh-Hant-TW': '繁體中文(台灣)',
16 'pt-BR': 'Português (Brasil)',
17 'pt-PT': 'Português (Portugal)',
21 'zh-Hans-CN': '简体中文(中国)'
24 const I18N_LOCALE_ALIAS = {
40 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
41 .concat(Object.keys(I18N_LOCALE_ALIAS))
43 export function getDefaultLocale () {
47 export function isDefaultLocale (locale: string) {
48 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
51 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
52 return translations && translations[str] ? translations[str] : str
55 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
56 export function is18nPath (path: string) {
57 return possiblePaths.indexOf(path) !== -1
60 export function is18nLocale (locale: string) {
61 return POSSIBLE_LOCALES.indexOf(locale) !== -1
64 export function getCompleteLocale (locale: string) {
65 if (!locale) return locale
67 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
72 export function getShortLocale (locale: string) {
73 if (locale.indexOf('-') === -1) return locale
75 return locale.split('-')[0]
78 export function buildFileLocale (locale: string) {
79 const completeLocale = getCompleteLocale(locale)
81 return completeLocale.replace(/-/g, '_')