1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
14 'nl-NL': 'Nederlands',
18 'zh-Hant-TW': '繁體中文(台灣)',
19 'pt-BR': 'Português (Brasil)',
20 'pt-PT': 'Português (Portugal)',
25 'zh-Hans-CN': '简体中文(中国)'
28 const I18N_LOCALE_ALIAS = {
45 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
46 .concat(Object.keys(I18N_LOCALE_ALIAS))
48 export function getDefaultLocale () {
52 export function isDefaultLocale (locale: string) {
53 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
56 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
57 return translations && translations[str] ? translations[str] : str
60 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
61 export function is18nPath (path: string) {
62 return possiblePaths.indexOf(path) !== -1
65 export function is18nLocale (locale: string) {
66 return POSSIBLE_LOCALES.indexOf(locale) !== -1
69 export function getCompleteLocale (locale: string) {
70 if (!locale) return locale
72 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
77 export function getShortLocale (locale: string) {
78 if (locale.indexOf('-') === -1) return locale
80 return locale.split('-')[0]
83 export function buildFileLocale (locale: string) {
84 const completeLocale = getCompleteLocale(locale)
86 return completeLocale.replace(/-/g, '_')