Skip to content

Commit

Permalink
Merge pull request #5403 from abpframework/feat/5402
Browse files Browse the repository at this point in the history
feat: enable retrieving resource from LocalizationService
  • Loading branch information
bnymncoskuner authored Sep 15, 2020
2 parents 11a3903 + a177107 commit e76f615
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions npm/ng-packs/packages/core/src/lib/states/config.state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down

0 comments on commit e76f615

Please sign in to comment.