Skip to content

Commit bac49ff

Browse files
committed
providing static default language
1 parent 9d5ac68 commit bac49ff

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

src/app/app.module.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,14 @@ import { LocalizeParser, LocalizeRouterModule, LocalizeRouterSettings } from '@g
1313
import { localizeBrowserLoaderFactory } from './core/utils/localize-browser.loader';
1414
import { Location } from '@angular/common';
1515

16+
export const defaultLangFunction = (languages: string[], cachedLang?: string): string => {
17+
if (cachedLang && languages.includes(cachedLang)) {
18+
return cachedLang;
19+
} else {
20+
return 'ar';
21+
}
22+
};
23+
1624
@NgModule({
1725
declarations: [
1826
AppComponent,
@@ -41,9 +49,11 @@ import { Location } from '@angular/common';
4149
deps: [TranslateService, Location, LocalizeRouterSettings, HttpClient, TransferState],
4250
},
4351
initialNavigation: true,
52+
defaultLangFunction,
4453
}),
4554
],
4655
providers: [],
4756
bootstrap: [AppComponent]
4857
})
49-
export class AppModule { }
58+
export class AppModule {
59+
}

src/app/app.server.module.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NgModule } from '@angular/core';
22
import { ServerModule, ServerTransferStateModule } from '@angular/platform-server';
3-
import { AppModule } from './app.module';
3+
import { AppModule, defaultLangFunction } from './app.module';
44
import { AppComponent } from './app.component';
55
import { TranslateLoader, TranslateModule, TranslateService } from '@ngx-translate/core';
66
import { translateServerLoaderFactory } from './core/utils/translate-server.loader';
@@ -30,8 +30,10 @@ import { Location } from '@angular/common';
3030
deps: [TranslateService, Location, LocalizeRouterSettings, TransferState],
3131
},
3232
initialNavigation: true,
33+
defaultLangFunction,
3334
}),
3435
],
3536
bootstrap: [AppComponent],
3637
})
37-
export class AppServerModule {}
38+
export class AppServerModule {
39+
}

0 commit comments

Comments
 (0)