fix(front-end): set fallback lang
Some checks failed
Build and Deploy / build-and-push (push) Successful in 30s
Build and Deploy / deploy (push) Successful in 21s
Build and Deploy / test-backend (push) Successful in 36s
Build and Deploy / test-frontend (push) Successful in 1m5s
PR Checks / prettier-autofix (pull_request) Failing after 18s
PR Checks / security-sast (pull_request) Successful in 33s
PR Checks / test-backend (pull_request) Successful in 30s
PR Checks / test-frontend (pull_request) Successful in 1m7s
Some checks failed
Build and Deploy / build-and-push (push) Successful in 30s
Build and Deploy / deploy (push) Successful in 21s
Build and Deploy / test-backend (push) Successful in 36s
Build and Deploy / test-frontend (push) Successful in 1m5s
PR Checks / prettier-autofix (pull_request) Failing after 18s
PR Checks / security-sast (pull_request) Successful in 33s
PR Checks / test-backend (pull_request) Successful in 30s
PR Checks / test-frontend (pull_request) Successful in 1m7s
This commit is contained in:
@@ -60,7 +60,7 @@ export const appConfig: ApplicationConfig = {
|
|||||||
),
|
),
|
||||||
importProvidersFrom(
|
importProvidersFrom(
|
||||||
TranslateModule.forRoot({
|
TranslateModule.forRoot({
|
||||||
defaultLanguage: 'it',
|
fallbackLang: 'it',
|
||||||
loader: {
|
loader: {
|
||||||
provide: TranslateLoader,
|
provide: TranslateLoader,
|
||||||
useClass: StaticTranslateLoader,
|
useClass: StaticTranslateLoader,
|
||||||
@@ -75,7 +75,7 @@ export const appConfig: ApplicationConfig = {
|
|||||||
} | null;
|
} | null;
|
||||||
|
|
||||||
translate.addLangs([...SUPPORTED_LANGS]);
|
translate.addLangs([...SUPPORTED_LANGS]);
|
||||||
translate.setDefaultLang('it');
|
translate.setFallbackLang('it');
|
||||||
const requestedUrl =
|
const requestedUrl =
|
||||||
(typeof request?.url === 'string' && request.url) || router.url || '/';
|
(typeof request?.url === 'string' && request.url) || router.url || '/';
|
||||||
const lang = resolveLangFromUrl(requestedUrl);
|
const lang = resolveLangFromUrl(requestedUrl);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ describe('LanguageService', () => {
|
|||||||
const translate = {
|
const translate = {
|
||||||
currentLang: '',
|
currentLang: '',
|
||||||
addLangs: jasmine.createSpy('addLangs'),
|
addLangs: jasmine.createSpy('addLangs'),
|
||||||
setDefaultLang: jasmine.createSpy('setDefaultLang'),
|
setFallbackLang: jasmine.createSpy('setFallbackLang'),
|
||||||
use: jasmine.createSpy('use').and.callFake((lang: string) => {
|
use: jasmine.createSpy('use').and.callFake((lang: string) => {
|
||||||
translate.currentLang = lang;
|
translate.currentLang = lang;
|
||||||
onLangChange.next({ lang });
|
onLangChange.next({ lang });
|
||||||
@@ -75,6 +75,7 @@ describe('LanguageService', () => {
|
|||||||
const service = new LanguageService(translate, router);
|
const service = new LanguageService(translate, router);
|
||||||
|
|
||||||
expect(translate.use).toHaveBeenCalledWith('it');
|
expect(translate.use).toHaveBeenCalledWith('it');
|
||||||
|
expect((translate as any).setFallbackLang).toHaveBeenCalledWith('it');
|
||||||
expect(navigateSpy).toHaveBeenCalledTimes(1);
|
expect(navigateSpy).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
const firstCall = navigateSpy.calls.mostRecent();
|
const firstCall = navigateSpy.calls.mostRecent();
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export class LanguageService {
|
|||||||
private router: Router,
|
private router: Router,
|
||||||
) {
|
) {
|
||||||
this.translate.addLangs(this.supportedLangs);
|
this.translate.addLangs(this.supportedLangs);
|
||||||
this.translate.setDefaultLang('it');
|
this.translate.setFallbackLang('it');
|
||||||
this.translate.onLangChange.subscribe((event) => {
|
this.translate.onLangChange.subscribe((event) => {
|
||||||
const lang =
|
const lang =
|
||||||
typeof event.lang === 'string' ? event.lang.toLowerCase() : null;
|
typeof event.lang === 'string' ? event.lang.toLowerCase() : null;
|
||||||
|
|||||||
Reference in New Issue
Block a user