Skip to content

Commit

Permalink
Fix translate pipe not working
Browse files Browse the repository at this point in the history
by exporting app module and importing in sub module.
  • Loading branch information
stangahh committed Jul 25, 2018
1 parent 2174664 commit 5afab42
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/app/@theme/theme.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ModuleWithProviders, NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { TranslateModule } from '@ngx-translate/core';

import {
NbActionsModule,
Expand Down Expand Up @@ -43,7 +44,7 @@ import { DEFAULT_THEME } from './styles/theme.default';
import { COSMIC_THEME } from './styles/theme.cosmic';
import { CORPORATE_THEME } from './styles/theme.corporate';

const BASE_MODULES = [CommonModule, FormsModule, ReactiveFormsModule];
const BASE_MODULES = [CommonModule, FormsModule, ReactiveFormsModule, TranslateModule];

const NB_MODULES = [
NbCardModule,
Expand Down
6 changes: 5 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,15 @@ import { AnalyticsService } from './@core/utils/analytics.service';
export class AppComponent implements OnInit {
constructor(
public electronService: ElectronService,
private translate: TranslateService,
public translate: TranslateService,
private analytics: AnalyticsService
) {

translate.addLangs(['en', 'fr', 'cn']);
translate.setDefaultLang('en');
const browserLang = translate.getBrowserLang();
translate.use(browserLang.match(/en|fr|cn/) ? browserLang : 'en');

console.log('AppConfig', AppConfig);

if (electronService.isElectron()) {
Expand Down
1 change: 1 addition & 0 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export function HttpLoaderFactory(http: HttpClient) {
}
})
],
exports: [TranslateModule],
providers: [
ElectronService,
{ provide: APP_BASE_HREF, useValue: '/' }
Expand Down

0 comments on commit 5afab42

Please sign in to comment.