[go: nahoru, domu]

Skip to content
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

Feature(messageformat): Global variables for message formats #778

Open
1 task done
bartoszredziniak opened this issue Jun 30, 2024 · 0 comments
Open
1 task done

Comments

@bartoszredziniak
Copy link

Is there an existing issue for this?

  • I have searched the existing issues

Which Transloco package(s) will this feature affect?

Transloco, MessageFormat

Is your feature request related to a problem? Please describe

No response

Describe the solution you'd like

I want to have the possibility to declare global variables, which can be used in select translations with MessageFormat.
For example, I want to have a translation like this:
{ "mySelectRule": "{myVar, select, val1 {Value 1} val2 {Value 2} other {Other Value}}" }
And use it without having to declare params in each use in the template:
{{ 'mySelectRule' | transloco }}
I'd like to set this param in a service or component class for each translation as a global param, e.g.:
this.translocoService.setGlobalParam('myVar', 'val2')
Currently, I have to pass this value each time, even though it is often the same value:
{{ 'mySelectRule' | transloco : {myVar: 'val2'} }}
This can be very useful, e.g., with user gender, because a lot of content can depend on this value.

Describe alternatives you've considered

Alternatively, it would be nice to be able to create an interceptor that could modify parameters before translation(something like headers in http interceptor)

Additional context

No response

I would like to make a pull request for this feature

No

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

No branches or pull requests

1 participant