1- import { ServiceIdentifier } from '../Type/Enum/index.js' ;
2- import i18next , { i18n } from 'i18next' ;
3- import { LanguageService } from "./LanguageService" ;
4- import { EventDispatcher , ServiceResolver } from "@ember-nexus/app-core/Service" ;
5-
6- import en from "../Asset/Translation/en.json" ;
7- import de from "../Asset/Translation/de.json" ;
8- import no from "../Asset/Translation/no.json" ;
9- import ko from "../Asset/Translation/ko.json" ;
1+ import { EventDispatcher , ServiceResolver } from '@ember-nexus/app-core/Service' ;
2+ import { EventInterface } from '@ember-nexus/app-core/Type/Definition' ;
3+ import i18next , { i18n } from 'i18next' ;
104
11- import ar from "../Asset/Translation/ar.json" ;
12- import es from "../Asset/Translation/es.json" ;
13- import fr from "../Asset/Translation/fr.json" ;
14- import hi from "../Asset/Translation/hi.json" ;
15- import it from "../Asset/Translation/it.json" ;
16- import ja from "../Asset/Translation/ja.json" ;
17- import ru from "../Asset/Translation/ru.json" ;
18- import sw from "../Asset/Translation/sw.json" ;
19- import zhCN from "../Asset/Translation/zh-CN.json" ;
20- import { LanguageChangeEvent } from "../Event" ;
21- import { EventInterface } from "@ember-nexus/app-core/Type/Definition" ;
5+ import { LanguageService } from './LanguageService.js' ;
6+ import ar from '../Asset/Translation/ar.json' ;
7+ import de from '../Asset/Translation/de.json' ;
8+ import en from '../Asset/Translation/en.json' ;
9+ import es from '../Asset/Translation/es.json' ;
10+ import fr from '../Asset/Translation/fr.json' ;
11+ import hi from '../Asset/Translation/hi.json' ;
12+ import it from '../Asset/Translation/it.json' ;
13+ import ja from '../Asset/Translation/ja.json' ;
14+ import ko from '../Asset/Translation/ko.json' ;
15+ import no from '../Asset/Translation/no.json' ;
16+ import ru from '../Asset/Translation/ru.json' ;
17+ import sw from '../Asset/Translation/sw.json' ;
18+ import zhCN from '../Asset/Translation/zh-CN.json' ;
19+ import { LanguageChangeEvent } from '../Event/index.js' ;
20+ import { ServiceIdentifier } from '../Type/Enum/index.js' ;
2221
2322class TranslationService {
2423 static identifier : ServiceIdentifier = ServiceIdentifier . translationService ;
@@ -27,34 +26,34 @@ class TranslationService {
2726
2827 constructor (
2928 languageService : LanguageService ,
30- private eventDispatcher : EventDispatcher
29+ private eventDispatcher : EventDispatcher ,
3130 ) {
32- this . i18nInstance = i18next . createInstance ( {
33- lng : languageService . getActiveLanguage ( ) ,
34- debug : true ,
35- fallbackLng : 'en' ,
36- resources : {
37- en : { translation : en } ,
38- de : { translation : de } ,
39- no : { translation : no } ,
40- ko : { translation : ko } ,
31+ this . i18nInstance = i18next . createInstance (
32+ {
33+ lng : languageService . getActiveLanguage ( ) ,
34+ debug : true ,
35+ fallbackLng : 'en' ,
36+ resources : {
37+ en : { translation : en } ,
38+ de : { translation : de } ,
39+ no : { translation : no } ,
40+ ko : { translation : ko } ,
4141
42- ar : { translation : ar } ,
43- es : { translation : es } ,
44- fr : { translation : fr } ,
45- hi : { translation : hi } ,
46- it : { translation : it } ,
47- ja : { translation : ja } ,
48- ru : { translation : ru } ,
49- sw : { translation : sw } ,
50- 'zh-CN' : { translation : zhCN } ,
51- }
52- } , ( ) => {
53- this . eventDispatcher . addListener (
54- LanguageChangeEvent . identifier ,
55- this
56- ) ;
57- } ) ;
42+ ar : { translation : ar } ,
43+ es : { translation : es } ,
44+ fr : { translation : fr } ,
45+ hi : { translation : hi } ,
46+ it : { translation : it } ,
47+ ja : { translation : ja } ,
48+ ru : { translation : ru } ,
49+ sw : { translation : sw } ,
50+ 'zh-CN' : { translation : zhCN } ,
51+ } ,
52+ } ,
53+ ( ) => {
54+ this . eventDispatcher . addListener ( LanguageChangeEvent . identifier , this ) ;
55+ } ,
56+ ) ;
5857 }
5958
6059 static constructFromServiceResolver ( serviceResolver : ServiceResolver ) : TranslationService {
@@ -66,18 +65,13 @@ class TranslationService {
6665
6766 onEvent ( event : EventInterface ) : void {
6867 if ( event . getIdentifier ( ) === LanguageChangeEvent . identifier ) {
69- console . log ( 'received language update in translation service' ) ;
70- console . log ( event ) ;
71- console . log ( ( event as LanguageChangeEvent ) . getLanguage ( ) ) ;
7268 this . i18nInstance . changeLanguage ( ( event as LanguageChangeEvent ) . getLanguage ( ) ) ;
7369 }
7470 }
7571
76- getI18nInstance ( ) : i18n
77- {
72+ getI18nInstance ( ) : i18n {
7873 return this . i18nInstance ;
7974 }
80-
8175}
8276
8377export { TranslationService } ;
0 commit comments