1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
14 'nl-NL': 'Nederlands',
17 'zh-Hant-TW': '繁體中文(台灣)',
18 'pt-BR': 'Português (Brasil)',
19 'pt-PT': 'Português (Portugal)',
23 'zh-Hans-CN': '简体中文(中国)'
26 const I18N_LOCALE_ALIAS = {
42 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
43 .concat(Object.keys(I18N_LOCALE_ALIAS))
45 export function getDefaultLocale () {
49 export function isDefaultLocale (locale: string) {
50 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
53 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
54 return translations && translations[str] ? translations[str] : str
57 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
58 export function is18nPath (path: string) {
59 return possiblePaths.indexOf(path) !== -1
62 export function is18nLocale (locale: string) {
63 return POSSIBLE_LOCALES.indexOf(locale) !== -1
66 export function getCompleteLocale (locale: string) {
67 if (!locale) return locale
69 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
74 export function getShortLocale (locale: string) {
75 if (locale.indexOf('-') === -1) return locale
77 return locale.split('-')[0]
80 export function buildFileLocale (locale: string) {
81 const completeLocale = getCompleteLocale(locale)
83 return completeLocale.replace(/-/g, '_')