Browse Source
Merge pull request #5403 from abpframework/feat/5402
feat: enable retrieving resource from LocalizationService
pull/5406/head
Bunyamin Coskuner
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
18 additions and
0 deletions
-
npm/ng-packs/packages/core/src/lib/services/config-state.service.ts
-
npm/ng-packs/packages/core/src/lib/services/localization.service.ts
-
npm/ng-packs/packages/core/src/lib/states/config.state.ts
|
|
|
@ -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[] |
|
|
|
|