Merge pull request #5403 from abpframework/feat/5402

feat: enable retrieving resource from LocalizationService
pull/5406/head
Bunyamin Coskuner 5 years ago committed by GitHub
commit e76f615fe4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,6 +49,10 @@ export class ConfigStateService {
return this.store.selectSnapshot(ConfigState.getLocalization(...args));
}
getLocalizationResource(...args: Parameters<typeof ConfigState.getLocalizationResource>) {
return this.store.selectSnapshot(ConfigState.getLocalizationResource(...args));
}
dispatchGetAppConfiguration() {
return this.store.dispatch(new GetAppConfiguration());
}

@ -70,6 +70,10 @@ export class LocalizationService {
return this.store.select(ConfigState.getLocalization(key, ...interpolateParams));
}
getResource(resourceName: string) {
return this.store.select(ConfigState.getLocalizationResource(resourceName));
}
/**
* Returns localized text with the given interpolation parameters in current language.
* @param key Localization key to replace with localized text

@ -128,6 +128,16 @@ export class ConfigState {
return selector;
}
static getLocalizationResource(resourceName: string) {
const selector = createSelector([ConfigState], (state: Config.State): {
[key: string]: string;
} => {
return state.localization.values[resourceName];
});
return selector;
}
static getLocalization(
key: string | Config.LocalizationWithDefault,
...interpolateParams: string[]

Loading…
Cancel
Save