Other translations

This commit is contained in:
Matteo Gheza 2022-03-01 00:07:51 +01:00
parent a020068d36
commit f01b866e53
7 changed files with 105 additions and 37 deletions

View File

@ -27,7 +27,7 @@ export class DatetimePickerComponent implements OnInit, ControlValueAccessor {
}
ngOnInit(): void {
this.localeService.use('it');
this.localeService.use(window.navigator.language.split("-")[0]);
}
get value(): Date {

View File

@ -1,5 +1,6 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
import { TranslateService } from '@ngx-translate/core';
import { ApiClientService } from 'src/app/_services/api-client.service';
import { LatLng, latLng, tileLayer, Marker, Map } from 'leaflet';
import "leaflet.locatecontrol";
@ -34,7 +35,7 @@ export class MapPickerComponent implements OnInit {
isPlaceSearchResultsOpen = false;
placeSearchResults: any[] = [];
constructor(private toastr: ToastrService, private api: ApiClientService) {
constructor(private toastr: ToastrService, private api: ApiClientService, private translate: TranslateService) {
this.marker = (window as any).L.marker(latLng(0,0));
this.map = undefined as unknown as Map;
}
@ -95,7 +96,9 @@ export class MapPickerComponent implements OnInit {
searchPlace() {
if(this.placeName.length < 3) {
this.toastr.error("Il nome della località deve essere di almeno 3 caratteri");
this.translate.get('map_picker.place_min_length').subscribe((res: string) => {
this.toastr.error(res);
});
return;
}
this.api.get("places/search", {
@ -105,7 +108,9 @@ export class MapPickerComponent implements OnInit {
this.placeSearchResults = places;
}).catch((err) => {
console.error(err);
this.toastr.error("Errore di caricamento dei risultati della ricerca. Riprovare più tardi");
this.translate.get('map_picker.loading_error').subscribe((res: string) => {
this.toastr.error(res);
});
});
}

View File

@ -3,6 +3,7 @@ import { Router } from '@angular/router';
import { ApiClientService } from 'src/app/_services/api-client.service';
import { AuthService } from '../../_services/auth.service';
import { ToastrService } from 'ngx-toastr';
import { TranslateService } from '@ngx-translate/core';
import Swal from 'sweetalert2';
@Component({
@ -26,7 +27,8 @@ export class TableComponent implements OnInit, OnDestroy {
private api: ApiClientService,
public auth: AuthService,
private router: Router,
private toastr: ToastrService
private toastr: ToastrService,
private translate: TranslateService
) { }
getTime() {
@ -89,24 +91,31 @@ export class TableComponent implements OnInit, OnDestroy {
deleteService(id: number) {
console.log(id);
Swal.fire({
title: 'Sei del tutto sicuro di voler rimuovere l\'intervento?',
text: "Gli interventi eliminati non si possono recuperare.",
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Si, rimuovilo',
cancelButtonText: 'Annulla'
}).then((result) => {
if (result.isConfirmed) {
this.api.delete(`services/${id}`).then((response) => {
this.toastr.success('Intervento rimosso con successo.');
this.loadTableData();
}).catch((e) => {
this.toastr.error('Errore durante la rimozione dell\'intervento.');
});
}
})
this.translate.get(['table.yes_remove', 'table.cancel', 'table.remove_service_confirm', 'table.remove_service_text']).subscribe((res: { [key: string]: string; }) => {
console.log(res);
Swal.fire({
title: res['table.remove_service_confirm'],
text: res['table.remove_service_confirm_text'],
icon: 'warning',
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: res['table.yes_remove'],
cancelButtonText: res['table.cancel']
}).then((result) => {
if (result.isConfirmed) {
this.api.delete(`services/${id}`).then((response) => {
this.translate.get('table.service_deleted_successfully').subscribe((res: string) => {
this.toastr.success(res);
});
this.loadTableData();
}).catch((e) => {
this.translate.get('table.service_deleted_error').subscribe((res: string) => {
this.toastr.error(res);
});
});
}
});
});
}
}

View File

@ -3,6 +3,7 @@ import { ActivatedRoute } from '@angular/router';
import { FormBuilder, Validators } from '@angular/forms';
import { ApiClientService } from 'src/app/_services/api-client.service';
import { ToastrService } from 'ngx-toastr';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'app-edit-service',
@ -66,7 +67,8 @@ export class EditServiceComponent implements OnInit {
private route: ActivatedRoute,
private api: ApiClientService,
private toastr: ToastrService,
private fb: FormBuilder
private fb: FormBuilder,
private translate: TranslateService
) {
this.route.paramMap.subscribe(params => {
this.serviceId = params.get('id') || undefined;
@ -104,11 +106,15 @@ export class EditServiceComponent implements OnInit {
addType() {
if(this.newType.length < 2) {
this.toastr.error("Il nome della tipologia deve essere lungo almeno 2 caratteri");
this.translate.get('edit_service.type_must_be_two_characters_long').subscribe((res: string) => {
this.toastr.error(res);
});
return;
}
if(this.types.find(t => t.name == this.newType)) {
this.toastr.error("Il nome della tipologia è già in uso");
this.translate.get('edit_service.type_already_exists').subscribe((res: string) => {
this.toastr.error(res);
});
return;
}
this.api.post("service_types", {
@ -117,8 +123,12 @@ export class EditServiceComponent implements OnInit {
this.addingType = false;
this.newType = "";
console.log(type);
if(type === 1) this.toastr.success("Tipologia di servizio aggiunta con successo.");
this.loadTypes();
if(type == 1) {
this.translate.get('edit_service.type_added_successfully').subscribe((res: string) => {
this.toastr.success(res);
});
this.loadTypes();
}
});
}
@ -169,11 +179,15 @@ export class EditServiceComponent implements OnInit {
console.log(values);
this.api.post("services", values).then((res) => {
console.log(res);
this.toastr.success("Intervento aggiunto con successo.");
this.translate.get('edit_service.service_added_successfully').subscribe((res: string) => {
this.toastr.success(res);
});
this.submittingForm = false;
}).catch((err) => {
console.error(err);
this.toastr.error("Errore durante l'aggiunta dell'intervento");
this.translate.get('edit_service.service_add_failed').subscribe((res: string) => {
this.toastr.error(res);
});
this.submittingForm = false;
});
}

View File

@ -4,6 +4,7 @@ import { ModalAvailabilityScheduleComponent } from '../../_components/modal-avai
import { ApiClientService } from 'src/app/_services/api-client.service';
import { ToastrService } from 'ngx-toastr';
import { BsModalService, BsModalRef } from 'ngx-bootstrap/modal';
import { TranslateService } from '@ngx-translate/core';
import { AuthService } from 'src/app/_services/auth.service';
@Component({
@ -24,7 +25,8 @@ export class ListComponent implements OnInit {
private api: ApiClientService,
private auth: AuthService,
private toastr: ToastrService,
private modalService: BsModalService
private modalService: BsModalService,
private translate: TranslateService
) {
this.loadAvailability();
}
@ -56,7 +58,9 @@ export class ListComponent implements OnInit {
this.api.post("manual_mode", {
manual_mode: manual_mode
}).then((response) => {
this.toastr.success("Modalità manuale aggiornata con successo.");
this.translate.get('list.manual_mode_updated_successfully').subscribe((res: string) => {
this.toastr.success(res);
});
this.loadAvailability();
});
}

View File

@ -7,13 +7,22 @@
"logout": "Logout",
"hi": "hi"
},
"table": {
"yes_remove": "Yes, remove",
"cancel": "Cancel",
"remove_service_confirm": "Are you sure you want to remove this service?",
"remove_service_confirm_text": "This action cannot be undone.",
"service_deleted_successfully": "Service deleted successfully",
"service_deleted_error": "Service could not be deleted. Please try again."
},
"list": {
"your_availability_is": "You are:",
"enable_schedules": "Enable hour schedules",
"disable_schedules": "Disable hour schedules",
"update_schedules": "Update availability schedules",
"connect_telegram_bot": "Connect your account to the Telegram bot",
"tooltip_change_availability": "Change your availability to {{state}}"
"tooltip_change_availability": "Change your availability to {{state}}",
"manual_mode_updated_successfully": "Manual mode updated successfully"
},
"login": {
"username": "username",
@ -30,13 +39,22 @@
"hamlet": "hamlet",
"municipality": "municipality"
},
"map_picker": {
"place_min_length": "Place name must be at least 3 characters long",
"loading_error": "Error loading search results. Please try again later"
},
"edit_service": {
"select_start_datetime": "Select start date and time for the service",
"select_end_datetime": "Select end date and time for the service",
"insert_code": "Insert service code",
"other_crew_members": "Other crew members",
"select_type": "Select a type",
"select_service_type": "Select a service type"
"select_service_type": "Select a service type",
"type_must_be_two_characters_long": "Type must be at least 2 characters long",
"type_already_exists": "Type already exists",
"type_added_successfully": "Type added successfully",
"service_added_successfully": "Service added successfully",
"service_add_error": "Service could not be added. Please try again"
},
"update_availability_schedule": "Update availability schedule",
"save_changes": "Save changes",

View File

@ -7,13 +7,22 @@
"logout": "Logout",
"hi": "Ciao"
},
"table": {
"yes_remove": "Si, rimuovi",
"cancel": "Annulla",
"remove_service_confirm": "Sei sicuro di voler rimuovere questo intervento?",
"remove_service_confirm_text": "Questa operazione non può essere annullata.",
"service_deleted_successfully": "Intervento rimosso con successo",
"service_deleted_error": "Errore durante la rimozione dell'intervento. Riprova più tardi"
},
"list": {
"your_availability_is": "Attualmente sei:",
"enable_schedules": "Abilita programmazione oraria",
"disable_schedules": "Disattiva programmazione oraria",
"update_schedules": "Modifica orari disponibilità",
"connect_telegram_bot": "Collega l'account al bot Telegram",
"tooltip_change_availability": "Cambia la tua disponibilità in {{state}}"
"tooltip_change_availability": "Cambia la tua disponibilità in {{state}}",
"manual_mode_updated_successfully": "Modalità manuale aggiornata con successo"
},
"login": {
"username": "username",
@ -30,13 +39,22 @@
"hamlet": "frazione",
"municipality": "raggruppamento del comune"
},
"map_picker": {
"place_min_length": "Il nome della località deve essere di almeno 3 caratteri",
"loading_error": "Errore di caricamento dei risultati della ricerca. Riprovare più tardi"
},
"edit_service": {
"select_start_datetime": "Seleziona data e ora di inizio dell'intervento",
"select_end_datetime": "Seleziona data e ora di fine dell'intervento",
"insert_code": "Inserisci il progressivo dell'intervento",
"other_crew_members": "Altri membri della squadra",
"select_type": "Seleziona una tipologia",
"select_service_type": "Seleziona una tipologia di intervento"
"select_service_type": "Seleziona una tipologia di intervento",
"type_must_be_two_characters_long": "La tipologia deve essere di almeno 2 caratteri",
"type_already_exists": "La tipologia è già presente",
"type_added_successfully": "Tipologia aggiunta con successo",
"service_added_successfully": "Intervento aggiunto con successo",
"service_add_error": "Errore durante l'aggiunta dell'intervento. Riprovare più tardi"
},
"update_availability_schedule": "Aggiorna programmazione disponibilità",
"save_changes": "Salva modifiche",