You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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?
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
The text was updated successfully, but these errors were encountered:
I considered using the compiler to flatten the tree structure, but the downside is that it would need to process the entire file every time it's loaded.
For this reason, I believe introducing a hook is a more efficient and convenient solution, especially when working with large files. 😊
Here’s the situation we’re facing:
Support for multiple languages
A very large JSON file where translations are organized as a deeply nested tree structure
The translation pipe receives the key of a dictionary object (e.g., "dictionary" in my example), which we cannot change. As a result, instead of returning a translated string, it outputs [object Object] or the stringified dictionary itself
While the compiler could address this by rewriting the JSON files entirely, I believe the proposed hook provides a flexible approach and more performant for such cases, it can improve the consuming of the tree or array structures introduced.
It allows consumers of the library to define the desired behavior without affecting the library’s internal logic.
Uh oh!
There was an error while loading. Please reload this page.
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:
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
The text was updated successfully, but these errors were encountered: