1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES: any = {
13 'zh-Hant-TW': '繁體中文(台灣)',
14 'pt-BR': 'Português (Brasil)',
17 'zh-Hans-CN': '简体中文(中国)'
20 const I18N_LOCALE_ALIAS: any = {
33 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
34 .concat(Object.keys(I18N_LOCALE_ALIAS))
36 export function getDefaultLocale () {
40 export function isDefaultLocale (locale: string) {
41 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
44 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
45 return translations && translations[str] ? translations[str] : str
48 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
49 export function is18nPath (path: string) {
50 return possiblePaths.indexOf(path) !== -1
53 export function is18nLocale (locale: string) {
54 return POSSIBLE_LOCALES.indexOf(locale) !== -1
57 export function getCompleteLocale (locale: string) {
58 if (!locale) return locale
60 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
65 export function getShortLocale (locale: string) {
66 if (locale.indexOf('-') === -1) return locale
68 return locale.split('-')[0]
71 export function buildFileLocale (locale: string) {
72 const completeLocale = getCompleteLocale(locale)
74 return completeLocale.replace(/-/g, '_')