Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ddba3b5ff |
@@ -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]) });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user