Translator
This commit is contained in:
parent
833bacc378
commit
c120709d2e
@ -8,8 +8,9 @@
|
|||||||
"lint": "ng lint",
|
"lint": "ng lint",
|
||||||
"build:client-and-server-bundles": "ng build --prod && ng run explorer2-epic:server:production",
|
"build:client-and-server-bundles": "ng build --prod && ng run explorer2-epic:server:production",
|
||||||
"build:prerender": "npm run build:client-and-server-bundles && npm run compile:server && npm run generate:prerender",
|
"build:prerender": "npm run build:client-and-server-bundles && npm run compile:server && npm run generate:prerender",
|
||||||
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server",
|
"build:ssr": "npm run build:client-and-server-bundles && npm run compile:server && npm run move:build",
|
||||||
"compile:server": "tsc -p server.tsconfig.json",
|
"compile:server": "tsc -p server.tsconfig.json",
|
||||||
|
"move:build" : "(cp -r ./server/i18n/ dist/server)",
|
||||||
"generate:prerender": "cd dist && node prerender",
|
"generate:prerender": "cd dist && node prerender",
|
||||||
"serve:prerender": "cd dist/browser && http-server",
|
"serve:prerender": "cd dist/browser && http-server",
|
||||||
"serve:ssr": "node dist/server"
|
"serve:ssr": "node dist/server"
|
||||||
|
@ -2,6 +2,7 @@ import express from 'express';
|
|||||||
import { Request, Response, NextFunction } from 'express';
|
import { Request, Response, NextFunction } from 'express';
|
||||||
import { getRepository, getConnection } from 'typeorm';
|
import { getRepository, getConnection } from 'typeorm';
|
||||||
import { validationMiddleware } from '../middlewares';
|
import { validationMiddleware } from '../middlewares';
|
||||||
|
import * as path from 'path';
|
||||||
import {
|
import {
|
||||||
InternalServerErrorException,
|
InternalServerErrorException,
|
||||||
NoDataFoundException,
|
NoDataFoundException,
|
||||||
@ -455,19 +456,20 @@ export class BlockchainKernelController {
|
|||||||
next: NextFunction,
|
next: NextFunction,
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const lang = request.querylang;
|
const lang = request.query.lang;
|
||||||
|
|
||||||
response.status(200).json({
|
/* response.status(200).json({
|
||||||
status: 200,
|
status: 200,
|
||||||
timestamp: Date.now(),
|
timestamp: Date.now(),
|
||||||
message: 'Transaction fee chart fetched successfully',
|
message: 'Transaction fee chart fetched successfully',
|
||||||
response: {
|
response: {
|
||||||
lang: lang
|
lang: lang
|
||||||
},
|
},
|
||||||
});
|
}); */
|
||||||
|
console.log(path.resolve(__dirname + '/../i18n/'+request.query.lang+'.json'));
|
||||||
// res.header("Content-Type",'application/json');
|
console.log("Without :",path.resolve('/../i18n/'+request.query.lang+'.json'));
|
||||||
// res.sendFile(path.join(__dirname + '/../i18n/'+req.query.lang+'.json'));
|
response.header("Content-Type",'application/json');
|
||||||
|
response.sendFile(path.resolve(__dirname + '/../i18n/'+request.query.lang+'.json'));
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
next(new InternalServerErrorException(error));
|
next(new InternalServerErrorException(error));
|
||||||
|
41
server/i18n/de.json
Normal file
41
server/i18n/de.json
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
{
|
||||||
|
"home": {
|
||||||
|
"HEADER_TEXT": "Sie befinden sich in Testnet",
|
||||||
|
"COUNTDOWN": "Mainnet-Countdown",
|
||||||
|
"EXPLORE_IT": ", Entdecke es",
|
||||||
|
"VIEWALL": "Alle Diagramme anzeigen",
|
||||||
|
"BLOCKCHAIN_HEIGHT": "Blockchain Höhe",
|
||||||
|
"LATEST_BLOCK": "Letzter Block",
|
||||||
|
"LATEST_BLOCK1": "Neueste Block-Schwierigkeit & Erweiterungen",
|
||||||
|
"COIN_IN": "Münzen in Existenz",
|
||||||
|
"HEIGHT": "Höhe",
|
||||||
|
"HASH": "Hash",
|
||||||
|
"AGE": "Alter",
|
||||||
|
"FEE": "Gebühr",
|
||||||
|
"DIFFICULTY" : "Schwierigkeit",
|
||||||
|
"POW_ALGO" : "Pow Algo",
|
||||||
|
"INPUTS" : "Eingänge",
|
||||||
|
"OUTPUTS" : "Ausgänge",
|
||||||
|
"KERNELS" : "Kernel",
|
||||||
|
"EPIC" : "Epos",
|
||||||
|
"EXPLORE" : "Erkunden",
|
||||||
|
"AGO" : "vor",
|
||||||
|
"MINUTE" : "minute",
|
||||||
|
"TOTAL_DIFFICULTY" : "Gesamtschwierigkeit",
|
||||||
|
"TRANSACTIONS_BY_TIME" : "Transkationen nach Zeit",
|
||||||
|
"BLOCKS" : "Blöcke",
|
||||||
|
"BLOCK" : "Block",
|
||||||
|
"BLOCKS_MINED" : "Blöcke abgebaut",
|
||||||
|
"TRANSACTION_FEES" : "Transkationsgebühren",
|
||||||
|
"SUPPLY_GROWTH" : "Angebotswachstum",
|
||||||
|
"HASHRATE_GROWTH_CHART" : "HashRate-Wachstumstabelle",
|
||||||
|
"BLOCK INTERVAL" : "Sperrintervall",
|
||||||
|
"TRANSACTIONS_VS_DATE" : "Transaktionen gegen Datum",
|
||||||
|
"DAYS" : "Tage",
|
||||||
|
"MONTHS" : "Monate",
|
||||||
|
"WEEK" : "Woche",
|
||||||
|
"SEARCH_TEXT" : "Suche nach Hash oder Höhe",
|
||||||
|
"BLOCK_REWARD" : "Block Belohnung"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -3,30 +3,40 @@ import { NgModule } from '@angular/core';
|
|||||||
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
|
||||||
import { AppRoutingModule } from './app-routing.module';
|
import { AppRoutingModule } from './app-routing.module';
|
||||||
import { AppComponent } from './app.component';
|
import { AppComponent } from './app.component';
|
||||||
import { HttpClientModule, HttpClient } from '@angular/common/http';
|
import { HttpClientModule, HttpClient, HttpParams } from '@angular/common/http';
|
||||||
import { CookieService } from 'ngx-cookie-service';
|
import { CookieService } from 'ngx-cookie-service';
|
||||||
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
|
import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
|
||||||
import { TransServiceService } from './shared/services/trans-service.service';
|
import { TransServiceService } from './shared/services/trans-service.service';
|
||||||
|
import { ChartService} from './shared/services/chart.service';
|
||||||
import { NotFoundComponent } from './view/home/not-found/not-found.component';
|
import { NotFoundComponent } from './view/home/not-found/not-found.component';
|
||||||
import { Observable, of } from 'rxjs';
|
import { Observable, of } from 'rxjs';
|
||||||
import { map, catchError } from 'rxjs/operators';
|
import { map, catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
export class CustomLoader implements TranslateLoader {
|
export class CustomLoader extends ChartService implements TranslateLoader {
|
||||||
apiHost: string;
|
apiHost: string;
|
||||||
|
|
||||||
constructor(private http: HttpClient ) {
|
constructor(public http: HttpClient ) {
|
||||||
|
super(http)
|
||||||
}
|
}
|
||||||
|
|
||||||
public getTranslation(lang: String): Observable<any> {
|
public getTranslation(lang): Observable<any> {
|
||||||
|
|
||||||
return this.http.get(this.apiHost+'/Translation?lang='+lang).pipe(
|
// return this.http.get(this.apiHost+'/Translation?lang='+lang).pipe(
|
||||||
|
// map((res: any) => {
|
||||||
|
// console.log("Data got: ");
|
||||||
|
// console.log(res);
|
||||||
|
// return res;
|
||||||
|
// })
|
||||||
|
// );
|
||||||
|
let params = new HttpParams();
|
||||||
|
params = params.append('lang', lang);
|
||||||
|
return this.apiGetRequest(params,'/blockchain_kernel/translator').pipe(
|
||||||
map((res: any) => {
|
map((res: any) => {
|
||||||
console.log("Data got: ");
|
console.log("Data got: ");
|
||||||
console.log(res);
|
console.log(res);
|
||||||
return res;
|
return res;
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,7 +59,10 @@ export class CustomLoader implements TranslateLoader {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
],
|
],
|
||||||
providers: [TransServiceService,CookieService],
|
providers: [TransServiceService,CookieService,ChartService],
|
||||||
bootstrap: [AppComponent]
|
bootstrap: [AppComponent]
|
||||||
})
|
})
|
||||||
export class AppModule { }
|
export class AppModule {
|
||||||
|
constructor( ) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -16,7 +16,7 @@ export class ChartService {
|
|||||||
private server = environment.domain;
|
private server = environment.domain;
|
||||||
private socket;
|
private socket;
|
||||||
|
|
||||||
constructor(private http: HttpClient) {}
|
constructor(public http: HttpClient) {}
|
||||||
|
|
||||||
public createSocketConnection() {
|
public createSocketConnection() {
|
||||||
this.socket = io.connect(this.server);
|
this.socket = io.connect(this.server);
|
||||||
|
@ -9,11 +9,11 @@ export class TransServiceService{
|
|||||||
public langLabel: any = {};
|
public langLabel: any = {};
|
||||||
|
|
||||||
constructor(public translate : TranslateService,private cookie: CookieService) {
|
constructor(public translate : TranslateService,private cookie: CookieService) {
|
||||||
translate.addLangs(['en', 'es']);
|
translate.addLangs(['en', 'de']);
|
||||||
translate.setDefaultLang('en');
|
translate.setDefaultLang('en');
|
||||||
this.langLabel = {en: 'English', es: 'Spanish'};
|
this.langLabel = {en: 'English', es: 'German'};
|
||||||
// console.log('this.getCookie() ifconf',this.getCookie() != 'undefined' ? 1: 2);
|
// console.log('this.getCookie() ifconf',this.getCookie() != 'undefined' ? 1: 2);
|
||||||
console.log("(this.getCookie() && this.getCookie() != null) ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != null) ? this.getCurrentLang() : 'en'",(this.getCookie() && this.getCookie() != 'undefined') ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != 'undefined') ? this.getCurrentLang() : 'en');
|
// console.log("(this.getCookie() && this.getCookie() != null) ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != null) ? this.getCurrentLang() : 'en'",(this.getCookie() && this.getCookie() != 'undefined') ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != 'undefined') ? this.getCurrentLang() : 'en');
|
||||||
translate.use((this.getCookie() && this.getCookie() != 'undefined') ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != 'undefined') ? this.getCurrentLang() : 'en');
|
translate.use((this.getCookie() && this.getCookie() != 'undefined') ? this.getCookie() : (this.getCurrentLang() && this.getCurrentLang() != 'undefined') ? this.getCurrentLang() : 'en');
|
||||||
|
|
||||||
this.setCookie(this.getCurrentLang());
|
this.setCookie(this.getCurrentLang());
|
||||||
|
Loading…
Reference in New Issue
Block a user