diff --git a/app/package-lock.json b/app/package-lock.json index db1cc3f..743c813 100644 --- a/app/package-lock.json +++ b/app/package-lock.json @@ -17,12 +17,16 @@ "@angular/platform-browser-dynamic": "^16.0.0", "@angular/router": "^16.0.0", "@capacitor/app": "5.0.6", + "@capacitor/camera": "^5.0.7", "@capacitor/core": "5.5.0", + "@capacitor/device": "^5.0.6", "@capacitor/haptics": "5.0.6", "@capacitor/keyboard": "5.0.6", "@capacitor/preferences": "^5.0.6", "@capacitor/status-bar": "5.0.6", "@ionic/angular": "^7.0.0", + "@ngx-translate/core": "^15.0.0", + "@ngx-translate/http-loader": "^8.0.0", "@types/uuid": "^9.0.5", "ionicons": "^7.0.0", "rxjs": "~7.8.0", @@ -2571,6 +2575,14 @@ "@capacitor/core": "^5.0.0" } }, + "node_modules/@capacitor/camera": { + "version": "5.0.7", + "resolved": "https://registry.npmjs.org/@capacitor/camera/-/camera-5.0.7.tgz", + "integrity": "sha512-1Wk3Dk0UhhNHdBB07UrPvUOSL7Wi5gFZRyLY1LZL2awt34iqy2cnajtfJplFmEZHk8lD0i7NAl3HbkWm4td4OQ==", + "peerDependencies": { + "@capacitor/core": "^5.0.0" + } + }, "node_modules/@capacitor/cli": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/@capacitor/cli/-/cli-5.5.0.tgz", @@ -2689,6 +2701,14 @@ "tslib": "^2.1.0" } }, + "node_modules/@capacitor/device": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/@capacitor/device/-/device-5.0.6.tgz", + "integrity": "sha512-tmjK0H8IKbDLMcmzZzJPbV+9yLkKJ76QOdz4A7fZAOYx2GnFHsFngxldq/wKotGAJuDX/ih3ZzHNrzVguzlv2g==", + "peerDependencies": { + "@capacitor/core": "^5.0.0" + } + }, "node_modules/@capacitor/haptics": { "version": "5.0.6", "resolved": "https://registry.npmjs.org/@capacitor/haptics/-/haptics-5.0.6.tgz", @@ -3673,6 +3693,33 @@ "webpack": "^5.54.0" } }, + "node_modules/@ngx-translate/core": { + "version": "15.0.0", + "resolved": "https://registry.npmjs.org/@ngx-translate/core/-/core-15.0.0.tgz", + "integrity": "sha512-Am5uiuR0bOOxyoercDnAA3rJVizo4RRqJHo8N3RqJ+XfzVP/I845yEnMADykOHvM6HkVm4SZSnJBOiz0Anx5BA==", + "engines": { + "node": "^16.13.0 || >=18.10.0" + }, + "peerDependencies": { + "@angular/common": ">=16.0.0", + "@angular/core": ">=16.0.0", + "rxjs": "^6.5.5 || ^7.4.0" + } + }, + "node_modules/@ngx-translate/http-loader": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/@ngx-translate/http-loader/-/http-loader-8.0.0.tgz", + "integrity": "sha512-SFMsdUcmHF5OdZkL1CHEoSAwbP5EbAOPTLLboOCRRoOg21P4GJx+51jxGdJeGve6LSKLf4Pay7BkTwmE6vxYlg==", + "engines": { + "node": "^16.13.0 || >=18.10.0" + }, + "peerDependencies": { + "@angular/common": ">=16.0.0", + "@angular/core": ">=16.0.0", + "@ngx-translate/core": ">=15.0.0", + "rxjs": "^6.5.5 || ^7.4.0" + } + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", diff --git a/app/package.json b/app/package.json index f5ccb0f..4c57f10 100644 --- a/app/package.json +++ b/app/package.json @@ -38,7 +38,10 @@ "zone.js": "~0.13.0", "@capacitor/preferences": "^5.0.6", "@types/uuid": "^9.0.5", - "@capacitor/camera": "^5.0.7" + "@capacitor/camera": "^5.0.7", + "@capacitor/device": "^5.0.6", + "@ngx-translate/core": "^15.0.0", + "@ngx-translate/http-loader": "^8.0.0" }, "devDependencies": { "@angular-devkit/build-angular": "^16.0.0", diff --git a/app/src/app/app.component.ts b/app/src/app/app.component.ts index 913de3d..7bd1682 100644 --- a/app/src/app/app.component.ts +++ b/app/src/app/app.component.ts @@ -1,4 +1,6 @@ import { Component } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { DeviceLanguageService } from './services/language/device-language.service'; @Component({ selector: 'app-root', @@ -6,5 +8,12 @@ import { Component } from '@angular/core'; styleUrls: ['app.component.scss'], }) export class AppComponent { - constructor() {} + constructor( + private translateService: TranslateService, + private deviceLanguageService: DeviceLanguageService, + ) { + this.deviceLanguageService.getLanguageCode().subscribe((languageCode) => { + this.translateService.use(languageCode); + }); + } } diff --git a/app/src/app/app.module.ts b/app/src/app/app.module.ts index 7a974cc..d270a8a 100644 --- a/app/src/app/app.module.ts +++ b/app/src/app/app.module.ts @@ -6,8 +6,18 @@ import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; -import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http'; +import { + HTTP_INTERCEPTORS, + HttpClient, + HttpClientModule, +} from '@angular/common/http'; import { AuthInterceptor } from './interceptors/auth.interceptor'; +import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; +import { TranslateHttpLoader } from '@ngx-translate/http-loader'; + +export function createTranslateLoader(http: HttpClient) { + return new TranslateHttpLoader(http, './assets/i18n/', '.json'); +} @NgModule({ declarations: [AppComponent], @@ -16,6 +26,13 @@ import { AuthInterceptor } from './interceptors/auth.interceptor'; IonicModule.forRoot(), AppRoutingModule, HttpClientModule, + TranslateModule.forRoot({ + loader: { + provide: TranslateLoader, + useFactory: createTranslateLoader, + deps: [HttpClient], + }, + }), ], providers: [ { provide: RouteReuseStrategy, useClass: IonicRouteStrategy }, diff --git a/app/src/app/pages/forbidden/forbidden.module.ts b/app/src/app/pages/forbidden/forbidden.module.ts index d12f65d..5831ffc 100644 --- a/app/src/app/pages/forbidden/forbidden.module.ts +++ b/app/src/app/pages/forbidden/forbidden.module.ts @@ -7,9 +7,16 @@ import { IonicModule } from '@ionic/angular'; import { ForbiddenPageRoutingModule } from './forbidden-routing.module'; import { ForbiddenPage } from './forbidden.page'; +import { TranslateModule } from '@ngx-translate/core'; @NgModule({ - imports: [CommonModule, FormsModule, IonicModule, ForbiddenPageRoutingModule], + imports: [ + CommonModule, + FormsModule, + IonicModule, + ForbiddenPageRoutingModule, + TranslateModule, + ], declarations: [ForbiddenPage], }) export class ForbiddenPageModule {} diff --git a/app/src/app/pages/forbidden/forbidden.page.html b/app/src/app/pages/forbidden/forbidden.page.html index 1d7776d..3e76a9e 100644 --- a/app/src/app/pages/forbidden/forbidden.page.html +++ b/app/src/app/pages/forbidden/forbidden.page.html @@ -10,14 +10,11 @@ alt="403 Forbidden" class="forbidden-img" > -
- La pàgina que busques està prohibida per al teu rol. O bé ets un - trapella o és culpa nostra. -
-{{ 'FORBIDDEN_ERROR.MESSAGE' | translate }}
+- Disculpa, hi ha hagut un error intern. Torna a intentar-ho més tard. -
+{{ 'INTERNAL_ERROR.MESSAGE' | translate }}