- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 858
feat: Added formatter, values, path to MessageContext #1271
feat: Added formatter, values, path to MessageContext #1271
Conversation
Thank you for your contribution. The use-case for the message function, as mentioned in the documentation, is to support complex cases that cannot be handled by vue-i18n's formatter. In PR, it is possible to specify a message, but it is difficult to extract this message as a resource. This makes it difficult to integrate it into the translation workflow with localization service. This PR is great that can improve DX by supporting fomatter for message funciton, but it needs to solve the issue of integration with translation workflow. There is a feature in vue-i18n that allows you to reference a message called We can solve the problem of integration with translation workflows by making it possible to reference messages in the message function. However, at this time, we do not have a way to make the linked locale message available in the message function. |
@kazupon Am I understanding you correctly that there also needs to be a way to get the entire "messages" object inside the message function? If so, I've added both |
@fabis94 Sorry for my poor explanation. I add a {
hey: 'hey {x} {y}'.
hello: (ctx) => ctx.formatter.interpolate(ctx.linked('hey'), ctx.values, ctx.path).join('')
} |
@kazupon I've updated the PR to also include the functionality you requested |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, late response
Thank you for your contribution!
I’ll merge your PR, but several props (path
, formatter
, messages, and
locale`) of message context are not compatible for vue-i18n@v9.
I’ll write those to docs as a limitation
I appreciate your work!
thank you @kazupon! any ideas when this will be released as a new version? |
I'm preparing for release now |
If you use message function functionality, vue-i18n skips running the formatter on the results. I don't want this, I want to do some custom work in the message function, but then defer all of the formatting back to vue-i18n.
To make this possible I've added the formatter, all values and path into the MessageContext. I've added a test case for this as well.