ngx-translate-messageformat-compiler
ngx-translate-messageformat-compiler copied to clipboard
Global parameters / missing parameter handler
I'm wanting to use global parameters in translation strings, things I don't have to pass in all the time. eg . {ProductName} etc, where any string can just use that and it will be translated.
Either some kinda of global parameters, or a missing parameter handler where I can set these, or a pre-translate event where i can alter the passed in parameters adding the global ones there.
Is there any current way to do this?
That's an interesting idea, sounds useful. There's currently no way to do this that I'm aware of.
We have the same issue. The way we do it, is by using a custom loader and doing the replace when the translations are loaded.
Of course, that means we can't update the value of these parameters if they ever change during the lifetime of the app (unless the translations are reloaded).
I just ended up writing a wrapper class, in that wrapper class adding the common translation parameters to the parameters (or creating parameters if null), then call the translate service. works well enough, and live translations as we need. just would be nice if this was baked in, because I could see it being useful.