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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
11 additions and
4 deletions
-
npm/ng-packs/packages/core/src/lib/actions/session.actions.ts
-
npm/ng-packs/packages/core/src/lib/states/config.state.ts
-
npm/ng-packs/packages/core/src/lib/states/session.state.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'; |
|
|
|
|
|
|
|
@ -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 }))); |
|
|
|
|
|
|
|
@ -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) |
|
|
|
|