1 export const LOCALE_FILES = [ 'player', 'server' ]
3 export const I18N_LOCALES = {
14 'nl-NL': 'Nederlands',
18 'zh-Hant-TW': '繁體中文(台灣)',
19 'pt-BR': 'Português (Brasil)',
20 'pt-PT': 'Português (Portugal)',
25 'zh-Hans-CN': '简体中文(中国)'
28 const I18N_LOCALE_ALIAS = {
43 'zh-CN': 'zh-Hans-CN',
47 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
48 .concat(Object.keys(I18N_LOCALE_ALIAS))
50 export function getDefaultLocale () {
54 export function isDefaultLocale (locale: string) {
55 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
58 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
59 return translations && translations[str] ? translations[str] : str
62 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
63 export function is18nPath (path: string) {
64 return possiblePaths.indexOf(path) !== -1
67 export function is18nLocale (locale: string) {
68 return POSSIBLE_LOCALES.indexOf(locale) !== -1
71 export function getCompleteLocale (locale: string) {
72 if (!locale) return locale
74 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
79 export function getShortLocale (locale: string) {
80 if (locale.indexOf('-') === -1) return locale
82 return locale.split('-')[0]
85 export function buildFileLocale (locale: string) {
86 return getCompleteLocale(locale)