1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
18 'nl-NL': 'Nederlands',
21 'pt-BR': 'Português (Brasil)',
22 'pt-PT': 'Português (Portugal)',
26 'zh-Hans-CN': '简体中文(中国)',
27 'zh-Hant-TW': '繁體中文(台灣)'
30 const I18N_LOCALE_ALIAS = {
47 'zh-CN': 'zh-Hans-CN',
51 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
52 .concat(Object.keys(I18N_LOCALE_ALIAS))
54 export function getDefaultLocale () {
58 export function isDefaultLocale (locale: string) {
59 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
62 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
63 // FIXME: remove disable rule when the client is upgraded to typescript 3.7
64 // eslint-disable-next-line
65 return translations && translations[str] ? translations[str] : str
68 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
69 export function is18nPath (path: string) {
70 return possiblePaths.indexOf(path) !== -1
73 export function is18nLocale (locale: string) {
74 return POSSIBLE_LOCALES.indexOf(locale) !== -1
77 export function getCompleteLocale (locale: string) {
78 if (!locale) return locale
80 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
85 export function getShortLocale (locale: string) {
86 if (locale.indexOf('-') === -1) return locale
88 return locale.split('-')[0]
91 export function buildFileLocale (locale: string) {
92 return getCompleteLocale(locale)