fixed translation

This commit is contained in:
2024-06-02 19:37:41 +05:00
parent 4f525b2632
commit 6ddba3b5ff

View File

@@ -12,7 +12,7 @@ import { Component, Input } from '@angular/core';
export class TextListComponent {
constructor(private http: HttpClient) {}
private _elements: string[] = [];
translated_text: string = '';
@Input() set elements(el: string[]) {
this._elements = el;
}
@@ -27,10 +27,12 @@ export class TextListComponent {
}
sendToTranslate($text: string) {
console.log($text);
$text = encodeURIComponent($text);
console.log(this.elements);
//TODO: говно какое-та не хочет отправлять целиком
this.http
.get(`https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=ru&dt=t&q=` + $text)
.subscribe({ next: (data: any) => console.log(data) });
.subscribe({ next: (data: any) => (this.translated_text = data[0][0][0]) });
}
}