62/5000
Hello everyone,
I have a problem, my translation does not work
app.module.ts
import {Http, HttpModule} from '@angular/http';
import {TranslateHttpLoader} from '@ngx-translate/http-loader';
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { HttpClientModule, HttpClient } from '@angular/common/http';
//api
import { ErrorHandler, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { SplashScreen } from '@ionic-native/splash-screen';
import { SQLite } from '@ionic-native/sqlite';
import { StatusBar } from '@ionic-native/status-bar';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
//page
import { AboutPage } from '../pages/about/about';
import { ContactPage } from '../pages/contact/contact';
import { HomePage } from '../pages/home/home';
import { LoginPage } from '../pages/login/login';
import { SignupPage } from '../pages/signup/signup';
import { TabsPage } from '../pages/tabs/tabs';
import { WelcomePage } from '../pages/welcome/welcome';
import { MyApp } from './app.component';
import { SelectionPage } from '../pages/selection/selection';
import { TallyPage } from '../pages/tally/tally';
import { StatementPage } from '../pages/statement/statement';
import { SummaryPage } from '../pages/summary/summary';
export function createTranslateLoader(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', 'fr.json');
}
@NgModule({
declarations: [
MyApp,
AppComponent,
WelcomePage,
StatementPage,
SummaryPage,
TallyPage,
SelectionPage,
LoginPage,
SignupPage,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
imports: [
BrowserModule,
FormsModule,
IonicModule.forRoot(MyApp),
HttpModule,
HttpClientModule,
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: ( createTranslateLoader ),
deps: [HttpClient]
}
})
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
AppComponent,
WelcomePage,
SummaryPage,
StatementPage,
TallyPage,
SelectionPage,
LoginPage,
SignupPage,
AboutPage,
ContactPage,
HomePage,
TabsPage
],
providers: [
StatusBar,
SplashScreen,
SQLite,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]
})
export class AppModule {}
app.component.ts
import { Component } from '@angular/core';
import { Platform } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { TranslateService } from '@ngx-translate/core';
import { WelcomePage } from '../pages/welcome/welcome';
@Component({
templateUrl: 'app.html',
})
export class MyApp {
rootPage:any = WelcomePage;
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen, public translateService: TranslateService,) {
this.translateService.setDefaultLang('en');
this.translateService.use('fr');
platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
statusBar.styleDefault();
splashScreen.hide();
});
}
}
and welcome.html
<ion-content padding id="Welcome">
<h1>{{ 'tally' | translate }}</h1>
<div>decouverte de la connection</div>
<button ion-button block class="margintop" (tap)="SignupPage()">signup</button>
<button ion-button block color="danger" (tap)="LoginPage()">Login</button>
</ion-content>
thanks
ludo