74 lines
2.2 KiB
TypeScript
74 lines
2.2 KiB
TypeScript
import {
|
|
ApplicationConfig,
|
|
inject,
|
|
provideAppInitializer,
|
|
provideBrowserGlobalErrorListeners,
|
|
} from '@angular/core';
|
|
import { provideAnimationsAsync } from '@angular/platform-browser/animations/async';
|
|
import { provideRouter, withInMemoryScrolling } from '@angular/router';
|
|
import { provideStore } from '@ngrx/store';
|
|
|
|
import { routes } from './app.routes';
|
|
import {
|
|
TranslateLoader,
|
|
TranslationObject,
|
|
provideTranslateService,
|
|
} from '@ngx-translate/core';
|
|
import { Observable, of } from 'rxjs';
|
|
|
|
import { IconRegistryService, deviceConfigsReducer, featureKey } from '@pi/ui';
|
|
|
|
/**
|
|
* Diccionario en línea: la librería resuelve los textos con `| translate`, y
|
|
* montar el loader HTTP real exigiría ficheros de i18n que no forman parte de
|
|
* la librería. Con las claves que faltan ngx-translate devuelve la propia
|
|
* clave, que para un catálogo de componentes es suficiente.
|
|
*/
|
|
const TRANSLATIONS: TranslationObject = {
|
|
common: {
|
|
close: 'Cerrar',
|
|
min: 'Mín',
|
|
max: 'Máx',
|
|
save: 'Guardar',
|
|
reset: 'Borrar',
|
|
search: 'Buscar…',
|
|
noResults: 'Sin resultados',
|
|
validator: {
|
|
requiredField: 'Este campo es obligatorio',
|
|
onlyNumbers: 'Sólo se admiten números',
|
|
enterValidEmail: 'Introduce un email válido',
|
|
minimumPasswordCharacters: 'La contraseña es demasiado corta',
|
|
},
|
|
},
|
|
};
|
|
|
|
class PlaygroundTranslateLoader implements TranslateLoader {
|
|
getTranslation(): Observable<TranslationObject> {
|
|
return of(TRANSLATIONS);
|
|
}
|
|
}
|
|
|
|
export const appConfig: ApplicationConfig = {
|
|
providers: [
|
|
provideBrowserGlobalErrorListeners(),
|
|
provideAnimationsAsync(),
|
|
|
|
provideRouter(
|
|
routes,
|
|
// Al cambiar de página se vuelve arriba; el catálogo es muy largo.
|
|
withInMemoryScrolling({ scrollPositionRestoration: 'top' }),
|
|
),
|
|
|
|
// Los iconos son SVG registrados en el MatIconRegistry (assets/icons).
|
|
provideAppInitializer(() => inject(IconRegistryService).init()),
|
|
|
|
provideTranslateService({
|
|
fallbackLang: 'es',
|
|
loader: { provide: TranslateLoader, useClass: PlaygroundTranslateLoader },
|
|
}),
|
|
|
|
// data-table y background-image leen el tipo de dispositivo del store.
|
|
provideStore({ [featureKey]: deviceConfigsReducer }),
|
|
],
|
|
};
|