ngx-translate-messageformat-compiler icon indicating copy to clipboard operation
ngx-translate-messageformat-compiler copied to clipboard

Global parameters / missing parameter handler

Open revenz opened this issue 5 years ago • 3 comments

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?

revenz avatar Oct 28 '19 20:10 revenz

That's an interesting idea, sounds useful. There's currently no way to do this that I'm aware of.

lephyrus avatar Nov 28 '19 07:11 lephyrus

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).

lemoinem avatar Nov 28 '19 21:11 lemoinem

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.

revenz avatar Nov 28 '19 21:11 revenz