Browse Source

Merge pull request #11451 from abpframework/auto-merge/rel-5-0/841

Merge branch rel-5.1 with rel-5.0
pull/11452/head
Bunyamin Coskuner 4 years ago
committed by GitHub
parent
commit
8d39f407ff
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      npm/ng-packs/packages/core/src/lib/services/localization.service.ts
  2. 16
      npm/ng-packs/packages/theme-shared/src/lib/handlers/document-dir.handler.ts

7
npm/ng-packs/packages/core/src/lib/services/localization.service.ts

@ -25,11 +25,18 @@ export class LocalizationService {
/** /**
* Returns currently selected language * Returns currently selected language
* Even though this looks like it's redundant to return the same value as `getLanguage()`,
* it's actually not. This could be invoked any time, and the latestLang could be different from the
* sessionState.getLanguage() value.
*/ */
get currentLang(): string { get currentLang(): string {
return this.latestLang || this.sessionState.getLanguage(); return this.latestLang || this.sessionState.getLanguage();
} }
get currentLang$(): Observable<string> {
return this.sessionState.getLanguage$();
}
get languageChange$(): Observable<string> { get languageChange$(): Observable<string> {
return this._languageChange$.asObservable(); return this._languageChange$.asObservable();
} }

16
npm/ng-packs/packages/theme-shared/src/lib/handlers/document-dir.handler.ts

@ -1,7 +1,7 @@
import { getLocaleDirection, LocalizationService } from '@abp/ng.core'; import { getLocaleDirection, LocalizationService } from '@abp/ng.core';
import { Injectable, Injector } from '@angular/core'; import { Injectable, Injector } from '@angular/core';
import { BehaviorSubject } from 'rxjs'; import { BehaviorSubject } from 'rxjs';
import { map, startWith } from 'rxjs/operators'; import { map } from 'rxjs/operators';
import { LocaleDirection } from '../models/common'; import { LocaleDirection } from '../models/common';
@Injectable() @Injectable()
@ -14,17 +14,11 @@ export class DocumentDirHandlerService {
private listenToLanguageChanges() { private listenToLanguageChanges() {
const l10n = this.injector.get(LocalizationService); const l10n = this.injector.get(LocalizationService);
// will always listen, no need to unsubscribe // will always listen, no need to unsubscribe
l10n.languageChange$ l10n.currentLang$.pipe(map(locale => getLocaleDirection(locale))).subscribe(dir => {
.pipe( this.dir.next(dir);
startWith(l10n.currentLang), this.setBodyDir(dir);
map(locale => getLocaleDirection(locale)), });
)
.subscribe(dir => {
this.dir.next(dir);
this.setBodyDir(dir);
});
} }
private setBodyDir(dir: LocaleDirection) { private setBodyDir(dir: LocaleDirection) {

Loading…
Cancel
Save