translate service created

This commit is contained in:
2023-02-01 13:05:17 +01:00
parent 8483253a62
commit 36bfb90a29
4 changed files with 1878 additions and 154 deletions

View File

@@ -1 +1,2 @@
</nav>
<router-outlet></router-outlet>

View File

@@ -0,0 +1,21 @@
import { Injectable } from '@angular/core';
import { Translate } from '@google-cloud/translate/build/src/v2';
@Injectable({
providedIn: 'root'
})
export class TranslateService {
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;
}
}