Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.app.json",
"aot": true,
"assets": ["src/favicon.ico", "src/assets"],
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css"
Expand Down Expand Up @@ -81,7 +84,10 @@
"polyfills": "src/polyfills.ts",
"tsConfig": "tsconfig.spec.json",
"karmaConfig": "karma.conf.js",
"assets": ["src/favicon.ico", "src/assets"],
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
"src/styles.css"
Expand All @@ -97,7 +103,9 @@
"tsconfig.spec.json",
"e2e/tsconfig.json"
],
"exclude": ["**/node_modules/**"]
"exclude": [
"**/node_modules/**"
]
}
},
"e2e": {
Expand All @@ -115,5 +123,8 @@
}
}
},
"defaultProject": "ap-translator"
}
"defaultProject": "ap-translator",
"cli": {
"analytics": "c5b5df4a-d00b-4554-a8f7-1f4cc445c73e"
}
}
30 changes: 3 additions & 27 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions src/app/app.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.example-container {
width: 500px;
height: 300px;
border: 1px solid rgba(0, 0, 0, 0.5);
}

.example-sidenav-content {
display: flex;
height: 100%;
align-items: center;
justify-content: center;
}

.example-sidenav {
padding: 20px;
}

24 changes: 16 additions & 8 deletions src/app/services/translator.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,11 @@ export class TranslatorService {
.filter((e) => !e.originLanguage)
.forEach((langTo) => {
observables.push({
obs: this.translateTextRequest(
this.http,
this.getTranslationUrl(
obs: this.translateRestRequest(
this.http,
languageOrigin.languageId,
langTo.languageId,
languageOrigin.translation
)
),
languageTo: langTo.languageId,
});
Expand All @@ -51,11 +49,10 @@ export class TranslatorService {
.toPromise()
.then(
(res) => {
let lines: [] = res[0];
lines.forEach((line) => {
translatedText = translatedText + line[0];
console.log(res)
translatedText = res.data;
translatedRow[0].translation = translatedText;
});

},
(err) => {
translatedText = this.ERROR_IN_TRANSLATION;
Expand All @@ -71,6 +68,17 @@ export class TranslatorService {
return languages;
}

protected translateRestRequest(
http: HttpClient, from:string, to:string, text: string
): Observable<any> {
let body = {
text: text,
languageFrom: from,
languageTo: to
}
return http.post('https://app-translator-rest.herokuapp.com/translate',body);
}

protected translateTextRequest(
http: HttpClient,
url: string
Expand Down