Browse Source

Merge pull request #3942 from abpframework/fix/set-html-lang

Change html tag lang attribute when the language changed
pull/3950/head
Levent Arman Özak 6 years ago
committed by GitHub
parent
commit
221ee970c5
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      npm/ng-packs/packages/core/src/lib/actions/session.actions.ts
  2. 6
      npm/ng-packs/packages/core/src/lib/states/config.state.ts
  3. 7
      npm/ng-packs/packages/core/src/lib/states/session.state.ts

2
npm/ng-packs/packages/core/src/lib/actions/session.actions.ts

@ -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';

6
npm/ng-packs/packages/core/src/lib/states/config.state.ts

@ -231,9 +231,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 })));

7
npm/ng-packs/packages/core/src/lib/states/session.state.ts

@ -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