@@ -36,30 +36,25 @@ export type TranslatorOptions<T extends { [key: string]: unknown }> = {
3636
3737/** @public */
3838export abstract class BaseTranslator < T extends { [ key : string ] : unknown } = { [ key : string ] : unknown } > {
39- protected abstract currentDocumentLanguage : Language | null ;
40- protected abstract fallbackLanguage : Language ;
41- protected abstract handleLanguageChange : LanguageChangeHandler | null ;
42- isInitialized : boolean ;
43- protected abstract translations : T ;
39+ protected currentDocumentLanguage : Language | null ;
40+ protected fallbackLanguage : Language ;
41+ protected handleLanguageChange : LanguageChangeHandler | null ;
42+ public isInitialized : boolean ;
43+ protected translations : T ;
4444
45- constructor ( ) {
45+ constructor ( { fallbackLanguage, translations } : TranslatorOptions < T > ) {
46+ this . currentDocumentLanguage = null ;
47+ this . fallbackLanguage = fallbackLanguage ?? 'en' ;
48+ this . handleLanguageChange = null ;
4649 this . isInitialized = false ;
50+ this . translations = translations ;
4751 }
4852}
4953
5054/** @public */
5155export class Translator < T extends { [ key : string ] : unknown } > extends BaseTranslator < T > {
52- protected currentDocumentLanguage : Language | null ;
53- protected fallbackLanguage : Language ;
54- protected handleLanguageChange : LanguageChangeHandler | null ;
55- protected translations : T ;
56-
5756 constructor ( options : TranslatorOptions < T > ) {
58- super ( ) ;
59- this . currentDocumentLanguage = null ;
60- this . fallbackLanguage = options . fallbackLanguage ?? 'en' ;
61- this . handleLanguageChange = null ;
62- this . translations = options . translations ;
57+ super ( options ) ;
6358 }
6459
6560 @InitializedOnly
0 commit comments