import Logger from '@/utils/logger' ; import en from './en' ; import zh from './zh' ; import zh_tw from './zh-tw' ; import pl from './pl' ; import ru from './ru' ; import de from './de' ; import ko from './ko' ; import es from './es' ; import fr from './fr' ; import pt_br from './pt-br' ; import nl from './nl' ; import he from './he' ; export const DEFAULT_LANGUAGE = 'en' ; const dictionary = { en , zh , zh_tw , pl , ru , de , ko , es , fr , pt_br , nl , he , } ; export const Trans = { get defaultLanguage ( ) { return DEFAULT_LANGUAGE ; } , get supportedLanguages ( ) : string [ ] { return Object . keys ( dictionary ) ; } , loadLanguage ( lang ) { return dictionary [ lang ] ; } , isLangSupported ( lang ) { return this . supportedLanguages . includes ( lang ) ; } , buildI18nHandler ( lang = DEFAULT_LANGUAGE ) { let l ; if ( ! this . isLangSupported ( lang ) ) { Logger . warn ( `Can't find the current language "${ lang }", Using language "${ DEFAULT_LANGUAGE }" by default. Welcome contribution to https://github.com/Leecason/element-tiptap` ) ; l = DEFAULT_LANGUAGE ; } else { l = lang ; } const langObj = this . loadLanguage ( l ) ; return function t ( path ) : string { const target = path . split ( '.' ) . reduce ( ( prev , curr ) => { return prev [ curr ] ; } , langObj ) ; return target ; } ; } , } ;