Description
Current behavior
Currently, there is no way to modify an interpolable translation string before interpolation is applied by the parser.
Expected behavior
Introduce a hook or extension point that allows modification of the raw translation value before the interpolation phase begins.
I prefer to not touch the getValue logic because it is something that can put a lot of constraints to internal logic and future features or changes.
What is the motivation / use case for changing the behavior?
Consider the following translation object:
"dictionary": {
"_": "Dictionary default",
"key1": "key one {{placeholder}}",
"key2": "key two"
}
When using the translate service, the entire object under dictionary is passed to the parser, which processes all keys. However, there is no built-in way to manipulate or extract a specific value (e.g., only key1) or even to determine which key to resolve dynamically.
In such cases, being able to hook into the translation process and modify the raw translation value before interpolation would be beneficial.
How do you think that we should implement this?
I’ve submitted a proposed solution in the following PR: #1554