Feature: get array of parameters while extract
truthz03 opened this issue ยท 11 comments
Is there an existing issue for this?
- I have searched the existing issues
Is your feature request related to a problem? Please describe
I need a list of key parameters inside the extracted json file
Describe the solution you'd like
It would be nice to get an output like ngx-translate-extract does.
Current output:
`{
"core.license.selectFile": "Missing value for 'core.license.selectFile'",
"core.license.unableToGetFeatureValue": "Missing value for 'core.license.unableToGetFeatureValue'",
"core.license.upload": "Missing value for 'core.license.upload'"
}`
Exprected output:
`{
"core.license.selectFile": [],
"core.license.unableToGetFeatureValue": [
"feature"
],
"core.license.upload": []
}`
Code:
this.translateService.translate('core.license.unableToGetFeatureValue', { feature: 'LineName' });
As you can see "core.license.unableToGetFeatureValue" has a parameter named "feature" inside the translate function and I need this parameter inside the extract output.
Additional context
No response
I would like to make a pull request for this feature
No ๐
@truthz03 I don't understand, what's the feature? The keys manager's job is to extract the keys.
You can pass an array as a custom missing key value if you need it as an arrys.
@shaharkazaz Thanks for your answer.
Can you complete the command with this custom stuff. I don't know how this should work.
"transloco-keys-manager extract --file-format json ..."
@truthz03 This is why we have docs ๐
See defaultValue
under the options section
@shaharkazaz Sorry I missused the word "key" ๐
I don't need an array of keys, I need an array of parameters used inside the key (I updated my initial post)
I need this feature because I use the json output to add all keys including the parameters to a database
Currently I don't see an option to add the parameters to the json output or are I'm wrong?
@truthz03 You are correct, the only thing that's currently extracted are the keys.
Would love to see an example of an input/outpt of the other lib you mentioned.
@shaharkazaz
Look at the "Exprected output" above. This is how ngx-translate-extract is extracting the keys with parameters
But why an array?
Because there could be more than 1 parameter
That I understand ๐
Why represent the result as an array and not a string with the parameters in it?
To write the keys including the parameters into my db I need all parameters separately.
Parsing an array is easier than a string and probably faster.
And I also don't have to change anything inside my tool ^^
But if an array is not possible I will also take a string ๐
@truthz03 Anything is possible ๐
I don't think that the speed would be noticeable either way, this isn't a heavy lifting operation.
I need to think about what would be best for all the users of this lib since this is the first time this was raised.