Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch rel-5.1 with rel-5.0 #11451

Merged
merged 3 commits into from
Jan 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,18 @@ export class LocalizationService {

/**
* 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 {
return this.latestLang || this.sessionState.getLanguage();
}

get currentLang$(): Observable<string> {
return this.sessionState.getLanguage$();
}

get languageChange$(): Observable<string> {
return this._languageChange$.asObservable();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getLocaleDirection, LocalizationService } from '@abp/ng.core';
import { Injectable, Injector } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
import { map, startWith } from 'rxjs/operators';
import { map } from 'rxjs/operators';
import { LocaleDirection } from '../models/common';

@Injectable()
Expand All @@ -14,17 +14,11 @@ export class DocumentDirHandlerService {

private listenToLanguageChanges() {
const l10n = this.injector.get(LocalizationService);

// will always listen, no need to unsubscribe
l10n.languageChange$
.pipe(
startWith(l10n.currentLang),
map(locale => getLocaleDirection(locale)),
)
.subscribe(dir => {
this.dir.next(dir);
this.setBodyDir(dir);
});
l10n.currentLang$.pipe(map(locale => getLocaleDirection(locale))).subscribe(dir => {
this.dir.next(dir);
this.setBodyDir(dir);
});
}

private setBodyDir(dir: LocaleDirection) {
Expand Down