build: add i18n support

This commit is contained in:
2026-01-20 22:54:08 -03:00
parent 490b929fa9
commit 00209ce137
7 changed files with 51 additions and 3 deletions

View File

@@ -11,6 +11,8 @@ import { WebSqlite } from 'angular-web-sqlite';
import { Sqlite } from './services/sqlite';
import { tables } from '../migrations/20260117';
import { provideServiceWorker } from '@angular/service-worker';
import {provideTranslateService } from "@ngx-translate/core";
import {provideTranslateHttpLoader} from "@ngx-translate/http-loader";
export const appConfig: ApplicationConfig = {
providers: [
@@ -28,5 +30,13 @@ export const appConfig: ApplicationConfig = {
enabled: !isDevMode(),
registrationStrategy: 'registerWhenStable:30000',
}),
provideTranslateService({
loader: provideTranslateHttpLoader({
prefix: '/i18n/',
suffix: '.json'
}),
fallbackLang: 'en',
lang: 'en'
})
],
};

View File

@@ -1,5 +1,6 @@
import { Component } from '@angular/core';
import { Component, inject } from '@angular/core';
import { RouterOutlet } from '@angular/router';
import { TranslateService } from '@ngx-translate/core';
@Component({
selector: 'app-root',
@@ -7,4 +8,11 @@ import { RouterOutlet } from '@angular/router';
templateUrl: './app.html',
styles: [],
})
export class App {}
export class App {
private readonly translate = inject(TranslateService);
constructor() {
this.translate.addLangs(['en', 'es', 'pt']);
this.translate.setFallbackLang('en');
this.translate.use('en');
}
}