Browse Source

improvement(core): change localization key type

pull/2305/head
thediaval 7 years ago
parent
commit
8f2a1472ae
  1. 10
      npm/ng-packs/packages/core/src/lib/services/localization.service.ts

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

@ -4,6 +4,7 @@ import { Store } from '@ngxs/store';
import { noop, Observable } from 'rxjs';
import { ConfigState } from '../states/config.state';
import { registerLocale } from '../utils/initial-utils';
import { Config } from '../models/config';
type ShouldReuseRoute = (future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot) => boolean;
@ -21,7 +22,7 @@ export class LocalizationService {
@SkipSelf()
otherInstance: LocalizationService,
) {
if (otherInstance) throw new Error('LocaleService should have only one instance.');
if (otherInstance) throw new Error('LocalizationService should have only one instance.');
}
setRouteReuse(reuse: ShouldReuseRoute) {
@ -41,11 +42,14 @@ export class LocalizationService {
});
}
get(key: string, ...interpolateParams: string[]): Observable<string> {
get(
key: string | Config.LocalizationWithDefault,
...interpolateParams: string[]
): Observable<string> {
return this.store.select(ConfigState.getLocalization(key, ...interpolateParams));
}
instant(key: string, ...interpolateParams: string[]): string {
instant(key: string | Config.LocalizationWithDefault, ...interpolateParams: string[]): string {
return this.store.selectSnapshot(ConfigState.getLocalization(key, ...interpolateParams));
}
}

Loading…
Cancel
Save