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)',
24 'zh-Hans-CN': '简体中文(中国)'
27 const I18N_LOCALE_ALIAS = {
43 export const POSSIBLE_LOCALES = Object.keys(I18N_LOCALES)
44 .concat(Object.keys(I18N_LOCALE_ALIAS))
46 export function getDefaultLocale () {
50 export function isDefaultLocale (locale: string) {
51 return getCompleteLocale(locale) === getCompleteLocale(getDefaultLocale())
54 export function peertubeTranslate (str: string, translations?: { [ id: string ]: string }) {
55 return translations && translations[str] ? translations[str] : str
58 const possiblePaths = POSSIBLE_LOCALES.map(l => '/' + l)
59 export function is18nPath (path: string) {
60 return possiblePaths.indexOf(path) !== -1
63 export function is18nLocale (locale: string) {
64 return POSSIBLE_LOCALES.indexOf(locale) !== -1
67 export function getCompleteLocale (locale: string) {
68 if (!locale) return locale
70 if (I18N_LOCALE_ALIAS[locale]) return I18N_LOCALE_ALIAS[locale]
75 export function getShortLocale (locale: string) {
76 if (locale.indexOf('-') === -1) return locale
78 return locale.split('-')[0]
81 export function buildFileLocale (locale: string) {
82 const completeLocale = getCompleteLocale(locale)
84 return completeLocale.replace(/-/g, '_')