fixed translation
This commit is contained in:
@@ -12,7 +12,7 @@ import { Component, Input } from '@angular/core';
|
|||||||
export class TextListComponent {
|
export class TextListComponent {
|
||||||
constructor(private http: HttpClient) {}
|
constructor(private http: HttpClient) {}
|
||||||
private _elements: string[] = [];
|
private _elements: string[] = [];
|
||||||
|
translated_text: string = '';
|
||||||
@Input() set elements(el: string[]) {
|
@Input() set elements(el: string[]) {
|
||||||
this._elements = el;
|
this._elements = el;
|
||||||
}
|
}
|
||||||
@@ -27,10 +27,12 @@ export class TextListComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sendToTranslate($text: string) {
|
sendToTranslate($text: string) {
|
||||||
console.log($text);
|
$text = encodeURIComponent($text);
|
||||||
|
console.log(this.elements);
|
||||||
|
|
||||||
//TODO: говно какое-та не хочет отправлять целиком
|
//TODO: говно какое-та не хочет отправлять целиком
|
||||||
this.http
|
this.http
|
||||||
.get(`https://translate.googleapis.com/translate_a/single?client=gtx&sl=en&tl=ru&dt=t&q=` + $text)
|
.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]) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user