1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
14 'zh-Hant-TW': '繁體中文(台灣)',
15 'pt-BR': 'Português (Brasil)',
19 'zh-Hans-CN': '简体中文(中国)'
22 const I18N_LOCALE_ALIAS = {
36 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
37 .concat(Object.keys(I18N_LOCALE_ALIAS))
39 export function getDefaultLocale () {
43 export function isDefaultLocale (locale: string) {
44 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
47 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
48 return translations && translations[str] ? translations[str] : str
51 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
52 export function is18nPath (path: string) {
53 return possiblePaths.indexOf(path) !== -1
56 export function is18nLocale (locale: string) {
57 return POSSIBLE_LOCALES.indexOf(locale) !== -1
60 export function getCompleteLocale (locale: string) {
61 if (!locale) return locale
63 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
68 export function getShortLocale (locale: string) {
69 if (locale.indexOf('-') === -1) return locale
71 return locale.split('-')[0]
74 export function buildFileLocale (locale: string) {
75 const completeLocale = getCompleteLocale(locale)
77 return completeLocale.replace(/-/g, '_')