1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
13 'zh-Hant-TW': '中文 (繁體, 台灣)',
14 'pt-BR': 'Português (Brasil)',
19 const I18N_LOCALE_ALIAS = {
32 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
33 .concat(Object.keys(I18N_LOCALE_ALIAS))
35 export function getDefaultLocale () {
39 export function isDefaultLocale (locale: string) {
40 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
43 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
44 return translations && translations[str] ? translations[str] : str
47 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
48 export function is18nPath (path: string) {
49 return possiblePaths.indexOf(path) !== -1
52 export function is18nLocale (locale: string) {
53 return POSSIBLE_LOCALES.indexOf(locale) !== -1
56 export function getCompleteLocale (locale: string) {
57 if (!locale) return locale
59 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
64 export function getShortLocale (locale: string) {
65 if (locale.indexOf('-') === -1) return locale
67 return locale.split('-')[0]
70 export function buildFileLocale (locale: string) {
71 const completeLocale = getCompleteLocale(locale)
73 return completeLocale.replace(/-/g, '_')