@ngx-translate/core#TranslationChangeEvent TypeScript Examples

The following examples show how to use @ngx-translate/core#TranslationChangeEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: login.component.ts    From ng-devui-admin with MIT License 6 votes vote down vote up
ngOnInit(): void {
    this.translate
      .get('loginPage')
      .pipe(takeUntil(this.destroy$))
      .subscribe((res) => {
        this.i18nValues = this.translate.instant('loginPage');
        this.updateTabItems(res);
      });

    this.translate.onLangChange.pipe(takeUntil(this.destroy$)).subscribe((event: TranslationChangeEvent) => {
      this.i18nValues = this.translate.instant('loginPage');
      this.updateTabItems(this.i18nValues);
    });
    this.personalizeService.setRefTheme(ThemeType.Default);

    // oauth认证回调
    this.route.queryParams.pipe(map((param) => param.code)).subscribe((code) => {
      if (code && code.length > 0) {
        setTimeout(() => {
          this.toastMessage = [
            {
              severity: 'success',
              content: this.i18nValues['callbackMessage'],
            },
          ];
        });
      }
    });
  }
Example #2
Source File: register.component.ts    From ng-devui-admin with MIT License 6 votes vote down vote up
ngOnInit(): void {
    this.translate
      .get('registerPage')
      .pipe(takeUntil(this.destroy$))
      .subscribe((res) => {
        this.i18nValues = this.translate.instant('registerPage');
      });

    this.translate.onLangChange.pipe(takeUntil(this.destroy$)).subscribe((event: TranslationChangeEvent) => {
      this.i18nValues = this.translate.instant('registerPage');
    });
    this.language = this.translate.currentLang;
    this.personalizeService.setRefTheme(ThemeType.Default);
  }
Example #3
Source File: side-settings.component.ts    From ng-devui-admin with MIT License 6 votes vote down vote up
ngOnInit(): void {
    this.initLayoutConfig();

    if (localStorage.getItem('da-layout-id')) {
      this.layout = localStorage.getItem('da-layout-id');
    } else {
      this.layout = 'left-right';
    }

    this.translate
      .get('side-setting')
      .pipe(takeUntil(this.destroy$))
      .subscribe((res) => {
        this.i18nValues = this.translate.instant('side-setting');
        this.updateI18nItems(res);
      });

    this.translate.onLangChange.pipe(takeUntil(this.destroy$)).subscribe((event: TranslationChangeEvent) => {
      this.i18nValues = this.translate.instant('side-setting');
      this.updateI18nItems(this.i18nValues);
    });
  }
Example #4
Source File: pages.component.ts    From ng-devui-admin with MIT License 6 votes vote down vote up
ngOnInit() {
    this.translate
      .get('page')
      .pipe(takeUntil(this.destroy$))
      .subscribe((res) => {
        this.updateMenu(res);
      });

    this.translate.onLangChange.pipe(takeUntil(this.destroy$)).subscribe((event: TranslationChangeEvent) => {
      const values = this.translate.instant('page');
      this.updateMenu(values);
    });
    this.personalizeService.getUiTheme()!.subscribe((theme) => {
      const currentTheme = Object.values((window as { [key: string]: any })['devuiThemes']).find((i: Theme | unknown) => {
        return (i as Theme).id === theme;
      });
      if (currentTheme && (<any>currentTheme).isDark) {
        this.render2.addClass(document.body, 'is-dark');
      } else {
        this.render2.removeClass(document.body, 'is-dark');
      }
    });
  }