diff --git a/src/app/home/home.component.html b/src/app/home/home.component.html
index 0084214..9bdba3c 100644
--- a/src/app/home/home.component.html
+++ b/src/app/home/home.component.html
@@ -52,14 +52,6 @@
{{luogo.location}}
-
-
-
- {{luogo.location}}
-
-
diff --git a/src/app/home/home.component.ts b/src/app/home/home.component.ts
index dd449f4..5941ebe 100644
--- a/src/app/home/home.component.ts
+++ b/src/app/home/home.component.ts
@@ -5,7 +5,7 @@ import {Locations} from "../interface/data";
import {Router} from "@angular/router";
import { TranslateService } from '../service/translate.service';
import {ReadTranslateJsonService} from "../service/readTranslateJsonService";
-import {translations} from "../interface/translations";
+import {homeTranslations} from "../interface/translations";
@@ -28,15 +28,14 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
suggerimentoAttivo: boolean = false;
suggerimento: string = '';
completamento: string = '';
- input: string = 'How are you?';
- translations: translations = {} as translations;
+ translations: homeTranslations = {} as homeTranslations;
constructor(private readjsonService: ReadjsonService, private router: Router, private translateService: TranslateService, private readTranslationJsonService: ReadTranslateJsonService) {
}
ngOnInit(): void {
- this.translations = this.readTranslationJsonService.getData();
+ this.translations = this.readTranslationJsonService.getHomeTranslations();
console.log("translations loaded", this.translations)
this.readjsonService.getLocations().subscribe(data => {
@@ -124,7 +123,6 @@ export class HomeComponent implements OnInit, AfterViewInit, OnDestroy {
this.translations.menuPlaces = await this.translateService.getData(this.translations.menuPlaces, lang);
this.translations.alertMessage = await this.translateService.getData(this.translations.alertMessage, lang);
this.translations.searchPlaceholder = await this.translateService.getData(this.translations.searchPlaceholder, lang);
- this.translations.menuNear = await this.translateService.getData(this.translations.menuNear, lang);
this.translations.searchButton = await this.translateService.getData(this.translations.searchButton, lang);
}
}
diff --git a/src/app/interface/translations.ts b/src/app/interface/translations.ts
index f143521..beadbe5 100644
--- a/src/app/interface/translations.ts
+++ b/src/app/interface/translations.ts
@@ -1,9 +1,14 @@
-export interface translations {
+export interface homeTranslations {
alertMessage: string;
translate: string;
searchButton: string;
searchPlaceholder: string;
menuPlaces: string;
- menuNear: string;
+}
+
+export interface listTranslations {
+ translate: string;
+ locationName: string;
+ distance: string;
}
diff --git a/src/app/list/list.component.html b/src/app/list/list.component.html
index 70fff06..3c24f74 100644
--- a/src/app/list/list.component.html
+++ b/src/app/list/list.component.html
@@ -1,13 +1,21 @@
+
+
+
+
- Posizione {{locationParams}} non trovata
+ {{translations.locationName}}{{locationParams}}
-
Distance: {{distance[i]}} km
+ {{translations.distance}}{{distance[i]}} km
@@ -21,7 +29,7 @@
{{waypoinst.name}}
-
Distance: {{distance[i]}} km
+ {{translations.distance}}{{distance[i]}} km
diff --git a/src/app/list/list.component.ts b/src/app/list/list.component.ts
index c69c564..0e6d1e2 100644
--- a/src/app/list/list.component.ts
+++ b/src/app/list/list.component.ts
@@ -3,6 +3,9 @@ import {Locations} from "../interface/data";
import {ReadjsonService} from "../service/readjson.service";
import {ActivatedRoute} from "@angular/router";
import {positionService} from "../service/position.service";
+import {listTranslations} from "../interface/translations";
+import {TranslateService} from "../service/translate.service";
+import {ReadTranslateJsonService} from "../service/readTranslateJsonService";
@Component({
selector: 'app-list',
@@ -20,11 +23,13 @@ export class ListComponent implements OnInit, OnChanges {
distance: number[] = [];
+ translations: listTranslations = {} as listTranslations
- constructor(private route: ActivatedRoute, private readjsonService: ReadjsonService, private positionService: positionService) {
+ constructor(private route: ActivatedRoute, private readjsonService: ReadjsonService, private positionService: positionService, private translateService: TranslateService, private readTranslationJsonService: ReadTranslateJsonService) {
}
async ngOnInit() {
+ this.translations = this.readTranslationJsonService.getListTransaltions();
this.route.params.subscribe(params => {
this.locationParams = params['location'];
});
@@ -98,5 +103,12 @@ export class ListComponent implements OnInit, OnChanges {
}, 2000);
}
+ async switchLanguage(lang: string) {
+ this.translations.translate = await this.translateService.getData(this.translations.translate, lang);
+ this.translations.distance = await this.translateService.getData(this.translations.distance, lang);
+ this.translations.locationName = await this.translateService.getData(this.translations.locationName, lang);
+
+ }
+
}
diff --git a/src/app/service/readTranslateJsonService.ts b/src/app/service/readTranslateJsonService.ts
index 3a2f38b..04b8609 100644
--- a/src/app/service/readTranslateJsonService.ts
+++ b/src/app/service/readTranslateJsonService.ts
@@ -1,27 +1,38 @@
import {Injectable} from '@angular/core';
import {HttpClient} from "@angular/common/http";
-import {translations} from "../interface/translations";
+import {homeTranslations} from "../interface/translations";
+import {listTranslations} from "../interface/translations";
@Injectable({
providedIn: 'root'
})
export class ReadTranslateJsonService {
- private translationData: translations = {} as translations;
+ private homeTranslations: homeTranslations = {} as homeTranslations;
+ private listTranslation: listTranslations = {} as listTranslations;
constructor(private http: HttpClient) {
- this.http.get('assets/i18n/en.json').subscribe(data => {
- this.translationData.alertMessage = data.alertMessage;
- this.translationData.translate = data.translate;
- this.translationData.searchButton = data.searchButton;
- this.translationData.searchPlaceholder = data.searchPlaceholder;
- this.translationData.menuPlaces = data.menuPlaces;
- this.translationData.menuNear = data.menuNear;
- console.log("data loaded", this.translationData)
+ this.http.get('assets/i18n/home/en.json').subscribe(data => {
+ this.homeTranslations.alertMessage = data.alertMessage;
+ this.homeTranslations.translate = data.translate;
+ this.homeTranslations.searchButton = data.searchButton;
+ this.homeTranslations.searchPlaceholder = data.searchPlaceholder;
+ this.homeTranslations.menuPlaces = data.menuPlaces;
+ console.log("data loaded", this.homeTranslations)
+ });
+
+ this.http.get('assets/i18n/list/en.json').subscribe(data => {
+ this.listTranslation.translate = data.translate;
+ this.listTranslation.distance = data.distance;
+ this.listTranslation.locationName = data.locationName;
+ console.log("data loaded", this.homeTranslations)
});
}
- getData(): translations {
- console.log("data loaded", this.translationData)
- return this.translationData;
+ getHomeTranslations(): homeTranslations {
+ return this.homeTranslations;
+ }
+
+ getListTransaltions(): listTranslations {
+ return this.listTranslation;
}
}
diff --git a/src/assets/i18n/detail/en.json b/src/assets/i18n/detail/en.json
new file mode 100644
index 0000000..e69de29
diff --git a/src/assets/i18n/en.json b/src/assets/i18n/home/en.json
similarity index 74%
rename from src/assets/i18n/en.json
rename to src/assets/i18n/home/en.json
index 45961f6..88c7c9f 100644
--- a/src/assets/i18n/en.json
+++ b/src/assets/i18n/home/en.json
@@ -3,6 +3,5 @@
"translate": "Translate",
"searchButton": "Search",
"searchPlaceholder": "Type here...",
- "menuPlaces": "Places",
- "menuNear": "Near"
+ "menuPlaces": "Places"
}
diff --git a/src/assets/i18n/list/en.json b/src/assets/i18n/list/en.json
new file mode 100644
index 0000000..12ccb12
--- /dev/null
+++ b/src/assets/i18n/list/en.json
@@ -0,0 +1,5 @@
+{
+ "translate": "Translate",
+ "locationName": "Position not foundß: ",
+ "distance": "Distance: "
+}