1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
13 'nl-NL': 'Nederlands',
16 'zh-Hant-TW': '繁體中文(台灣)',
17 'pt-BR': 'Português (Brasil)',
18 'pt-PT': 'Português (Portugal)',
22 'zh-Hans-CN': '简体中文(中国)'
25 const I18N_LOCALE_ALIAS = {
41 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
42 .concat(Object.keys(I18N_LOCALE_ALIAS))
44 export function getDefaultLocale () {
48 export function isDefaultLocale (locale: string) {
49 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
52 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
53 return translations && translations[str] ? translations[str] : str
56 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
57 export function is18nPath (path: string) {
58 return possiblePaths.indexOf(path) !== -1
61 export function is18nLocale (locale: string) {
62 return POSSIBLE_LOCALES.indexOf(locale) !== -1
65 export function getCompleteLocale (locale: string) {
66 if (!locale) return locale
68 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
73 export function getShortLocale (locale: string) {
74 if (locale.indexOf('-') === -1) return locale
76 return locale.split('-')[0]
79 export function buildFileLocale (locale: string) {
80 const completeLocale = getCompleteLocale(locale)
82 return completeLocale.replace(/-/g, '_')