import { langText } from './langText' ; import { langTextKeys } from './langText' ; class Lang { constructor ( ) { this . getLangType ( ) ; } private langType : number = 0 ; private getLangType ( ) { const userLang = document . documentElement . lang ; switch ( userLang ) { case 'zh' : case 'zh-CN' : case 'zh-Hans' : this . langType = 0 ; break ; case 'ja' : this . langType = 1 ; break ; case 'zh-Hant' : case 'zh-tw' : case 'zh-TW' : this . langType = 3 ; break ; default : this . langType = 2 ; break ; } } public transl ( name , ... arg ) { let content = langText [ name ] [ this . langType ] ; arg . forEach ( ( val ) => ( content = content . replace ( '{}' , val ) ) ) ; return content ; } } const lang = new Lang ( ) ; export { lang } ;