Skip to content

Commit

Permalink
Merge pull request #22 from registreerocks/translate
Browse files Browse the repository at this point in the history
translate
  • Loading branch information
Jonathan Ngbonga authored Jul 21, 2021
2 parents 2b032bf + 357afc9 commit 27355d7
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 7 deletions.
1 change: 1 addition & 0 deletions web-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
"@capacitor/keyboard": "1.0.2",
"@capacitor/status-bar": "1.0.2",
"@ionic/angular": "^5.5.2",
"@ngneat/transloco": "^2.22.0",
"angularx-qrcode": "^11.0.0",
"rxjs": "~6.6.0",
"tslib": "^2.0.0",
Expand Down
10 changes: 9 additions & 1 deletion web-client/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { HttpClientModule } from '@angular/common/http';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';
import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { TranslocoRootModule } from './transloco/transloco-root.module';

@NgModule({
declarations: [AppComponent],
entryComponents: [],
imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule],
imports: [
BrowserModule,
IonicModule.forRoot(),
AppRoutingModule,
HttpClientModule,
TranslocoRootModule,
],
providers: [{ provide: RouteReuseStrategy, useClass: IonicRouteStrategy }],
bootstrap: [AppComponent],
})
Expand Down
38 changes: 38 additions & 0 deletions web-client/src/app/transloco/transloco-root.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { HttpClient } from '@angular/common/http';
import { Injectable, NgModule } from '@angular/core';
import {
Translation,
translocoConfig,
TranslocoLoader,
TranslocoModule,
TRANSLOCO_CONFIG,
TRANSLOCO_LOADER,
} from '@ngneat/transloco';
import { environment } from '../../environments/environment';

@Injectable({ providedIn: 'root' })
export class TranslocoHttpLoader implements TranslocoLoader {
constructor(private http: HttpClient) {}

getTranslation(lang: string) {
return this.http.get<Translation>(`/assets/i18n/${lang}.json`);
}
}

@NgModule({
exports: [TranslocoModule],
providers: [
{
provide: TRANSLOCO_CONFIG,
useValue: translocoConfig({
availableLangs: ['en', 'fr'],
defaultLang: 'en',
// Remove this option if your application doesn't support changing language in runtime.
reRenderOnLangChange: true,
prodMode: environment.production,
}),
},
{ provide: TRANSLOCO_LOADER, useClass: TranslocoHttpLoader },
],
})
export class TranslocoRootModule {}
9 changes: 8 additions & 1 deletion web-client/src/app/views/landing/landing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,18 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { IonicModule } from '@ionic/angular';
import { TranslocoModule } from '@ngneat/transloco';
import { LandingPageRoutingModule } from './landing-routing.module';
import { LandingPage } from './landing.page';

@NgModule({
imports: [CommonModule, FormsModule, IonicModule, LandingPageRoutingModule],
imports: [
CommonModule,
FormsModule,
IonicModule,
LandingPageRoutingModule,
TranslocoModule,
],
declarations: [LandingPage],
})
export class LandingPageModule {}
11 changes: 6 additions & 5 deletions web-client/src/app/views/landing/landing.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,19 @@ <h1 class="ion-text-center font-black">NAUTILUS</h1>
shape="round"
color="warning"
routerLink="/register"
>CREATE WALLET
</ion-button>
transloco="LANDING.create"
></ion-button>
<ion-button
expand="block"
shape="round"
color="white"
fill="outline"
routerLink="/wallet"
>OPEN WALLET
</ion-button>
transloco="LANDING.open"
></ion-button>
</ion-col>
<ion-col size="12">
<p class="ion-text-center">Terms & conditions apply</p>
<p class="ion-text-center">Terms & Conditions apply</p>
</ion-col>
</ion-row>
</ion-grid>
Expand Down
3 changes: 3 additions & 0 deletions web-client/src/assets/i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"LANDING": { "create": "CREATE AN ACCOUNT", "open": "OPEN WALLET" }
}
1 change: 1 addition & 0 deletions web-client/src/assets/i18n/fr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{ "LANDING": { "create": "CREER UN COMPTE", "open": "OUVRIR PORTFEUILLE" } }
5 changes: 5 additions & 0 deletions web-client/transloco.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
rootTranslationsPath: "src/assets/i18n/",
langs: ["en", "fr"],
keysManager: {},
};

0 comments on commit 27355d7

Please sign in to comment.