fix(core): set language when call app config api

pull/3942/head
mehmet-erim 5 years ago
parent 8d2dc2fa65
commit d22ba8a919

@ -2,7 +2,7 @@ import { ABP } from '../models';
export class SetLanguage {
static readonly type = '[Session] Set Language';
constructor(public payload: string) {}
constructor(public payload: string, public dispatchAppConfiguration?: boolean) {}
}
export class SetTenant {
static readonly type = '[Session] Set Tenant';

@ -33,10 +33,9 @@ export class LocalizationService {
}
private listenToSetLanguage() {
this.actions.pipe(ofActionSuccessful(SetLanguage)).subscribe(({ payload }) => {
this.registerLocale(payload);
document.documentElement.lang = payload;
});
this.actions
.pipe(ofActionSuccessful(SetLanguage))
.subscribe(({ payload }) => this.registerLocale(payload));
}
setRouteReuse(reuse: ShouldReuseRoute) {

@ -219,9 +219,13 @@ export class ConfigState {
defaultLang = defaultLang.split(';')[0];
}
document.documentElement.setAttribute(
'lang',
configuration.localization.currentCulture.cultureName,
);
return this.store.selectSnapshot(SessionState.getLanguage)
? of(null)
: dispatch(new SetLanguage(defaultLang));
: dispatch(new SetLanguage(defaultLang, false));
}),
catchError(err => {
dispatch(new RestOccurError(new HttpErrorResponse({ status: 0, error: err })));

@ -69,12 +69,15 @@ export class SessionState {
}
@Action(SetLanguage)
setLanguage({ patchState, dispatch }: StateContext<Session.State>, { payload }: SetLanguage) {
setLanguage(
{ patchState, dispatch }: StateContext<Session.State>,
{ payload, dispatchAppConfiguration = true }: SetLanguage,
) {
patchState({
language: payload,
});
return dispatch(new GetAppConfiguration());
if (dispatchAppConfiguration) return dispatch(new GetAppConfiguration());
}
@Action(SetTenant)

Loading…
Cancel
Save