Skip to content

Translation transformer handler #1554

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 20 commits into
base: master
Choose a base branch
from

Conversation

victorlazzaroli
Copy link

@victorlazzaroli victorlazzaroli commented May 25, 2025

Introduce a hook or extension point that allows modification of the raw translation value before the interpolation phase begins.

Issue: #1555

CodeAndWeb and others added 20 commits February 21, 2025 11:06
…formatted TranslateDefaultParser

- All methods in the default parser are now protected to allow overriding
- added getInterpolationReplacement() to allow customization of the replacements (getting values from the parameter object and formatting)
- Improved formatter now renders Objects as JSON instead of [object Object]
- Arrays are rendered with ", " instead of just ","
…nslation text is found.

Isolated function to receive translation text from the translations with fallback to default language.
… TranslateStore to use better encapsulation. From outside, these event handlers are now visible as Observables and not EventEmitters to prevent users from outside calling emit().

Internally now using Subjects instead of EventEmitters.

ngx-translate#1513
Instead, the function now uses the currentLang and defaultLang internally to get the values from the store directly.
getValue() is protected and can be overwritten.
Fixed some lint warnings.
Add urls to link the repo with the npm page
@CodeAndWeb
Copy link
Member

We already have this functionality in form of the translate compiler.
It receives the translations before they are committed to the store.
The point in time is a bit earlier than your proposed hook.

@victorlazzaroli
Copy link
Author

I considered using the compiler to flatten the tree structure, but the cost is that it has to process the entire file every time it is loaded.
For this reason, I think it is more efficient and convenient to introduce the hook, especially for large files. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants