Added Translations
This commit is contained in:
27
src/app/service/readTranslateJsonService.ts
Normal file
27
src/app/service/readTranslateJsonService.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import {Injectable} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {translations} from "../interface/translations";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class ReadTranslateJsonService {
|
||||
private translationData: translations = {} as translations;
|
||||
|
||||
constructor(private http: HttpClient) {
|
||||
this.http.get<translations>('assets/i18n/en.json').subscribe(data => {
|
||||
this.translationData.alertMessage = data.alertMessage;
|
||||
this.translationData.translate = data.translate;
|
||||
this.translationData.searchButton = data.searchButton;
|
||||
this.translationData.searchPlaceholder = data.searchPlaceholder;
|
||||
this.translationData.menuPlaces = data.menuPlaces;
|
||||
this.translationData.menuNear = data.menuNear;
|
||||
console.log("data loaded", this.translationData)
|
||||
});
|
||||
}
|
||||
|
||||
getData(): translations {
|
||||
console.log("data loaded", this.translationData)
|
||||
return this.translationData;
|
||||
}
|
||||
}
|
||||
@@ -53,8 +53,4 @@ export class ReadjsonService{
|
||||
tap(data => console.log("data requested", data))
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,21 +1,16 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
//import { Translate } from '@google-cloud/translate/build/src/v2';
|
||||
|
||||
import {DeepLService} from "./deepL.service";
|
||||
import {Injectable} from "@angular/core";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TranslateService {
|
||||
constructor(private deepLService: DeepLService) {
|
||||
|
||||
//private translate: Translate;
|
||||
|
||||
// constructor() {
|
||||
// this.translate = new Translate({projectId: 'Modulo-152'});
|
||||
//}
|
||||
|
||||
//async translateText(text: string, target: string): Promise<string> {
|
||||
//const [translation] = await this.translate.translate(text, target);
|
||||
//return translation;
|
||||
//}
|
||||
}
|
||||
|
||||
async getData(input: string, lang: string): Promise<string> {
|
||||
const response = await this.deepLService.translate(input, lang).toPromise();
|
||||
return response.translations[0].text;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user