This commit is contained in:
crusader 2018-10-13 04:59:41 +09:00
parent a664e2cf0c
commit 80c6017ed0
2 changed files with 18 additions and 10 deletions

View File

@ -40,14 +40,15 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On
this.showTitleBar = false; this.showTitleBar = false;
this.block = false; this.block = false;
// this.translateService.onLangChange.subscribe(() => { this.translateService.addLangs(['en', 'ko']);
// this.changeDetector.detectChanges(); this.translateService.setDefaultLang('en');
// this.translateService.onLangChange.subscribe((e) => {
// this.changeDetector.markForCheck();
// }); // });
// this.translateService.onTranslationChange.subscribe(() => { // this.translateService.onTranslationChange.subscribe((e) => {
// this.changeDetector.detectChanges(); // this.changeDetector.detectChanges();
// }); // });
this.translateService.setDefaultLang('en');
// const i18ns = ['en', 'ko']; // const i18ns = ['en', 'ko'];
// i18ns.forEach((lang) => { // i18ns.forEach((lang) => {
@ -67,6 +68,7 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On
this.menuSubscription = this.electronProxyService.menuObservable() this.menuSubscription = this.electronProxyService.menuObservable()
.pipe( .pipe(
map((name: MenuEvent) => { map((name: MenuEvent) => {
let requireDetectChanges = true;
switch (name) { switch (name) {
case 'show-about': case 'show-about':
this.displayAbout = true; this.displayAbout = true;
@ -87,15 +89,23 @@ export class AppComponent implements OnInit, AfterContentInit, AfterViewInit, On
this.displayPrint = true; this.displayPrint = true;
break; break;
case 'change-language-english': case 'change-language-english':
this.translateService.use('en'); requireDetectChanges = false;
this.translateService.use('en').pipe(take(1)).subscribe((res: any) => {
__this.changeDetector.detectChanges();
});
break; break;
case 'change-language-korean': case 'change-language-korean':
this.translateService.use('ko'); requireDetectChanges = false;
this.translateService.use('ko').pipe(take(1)).subscribe((res: any) => {
__this.changeDetector.detectChanges();
});
break; break;
default: default:
break; break;
} }
__this.changeDetector.detectChanges(); if (requireDetectChanges) {
__this.changeDetector.detectChanges();
}
}), }),
catchError(error => { catchError(error => {
return of(error); return of(error);

View File

@ -4,9 +4,7 @@ import { Observable, of } from 'rxjs';
import { TranslateLoader } from '@ngx-translate/core'; import { TranslateLoader } from '@ngx-translate/core';
import { ElectronProxyService } from './electron-proxy.service'; import { ElectronProxyService } from './electron-proxy.service';
@Injectable({ @Injectable()
providedIn: 'root'
})
export class I18nService extends TranslateLoader { export class I18nService extends TranslateLoader {
private prefix: string; private prefix: string;
private suffix: string; private suffix: string;