-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
feat: supports selecting the overwrite order of merge messages #1896
base: master
Are you sure you want to change the base?
Conversation
I don't quite understand the use case and implementation, this would basically loop through the messages object without doing anything when |
|
I think you would get the desired result by calling |
That means I need to call mergeLocaleMessage twice, the first time passing in what I need to merge, and the second time passing in what I originally wanted, to achieve the overwriting situation. This is indeed a solution, but if it can be directly supported from mergeLocaleMessage, I believe it will be more readable and have higher performance. |
I resubmitted the code. When the |
Compared with the original version: |
Ideally you should be able to have some control over the priority/order of loading and setting messages in your project. In Nuxt I18n we rely on this behavior heavily, adding additional comparisons in the Can you provide a minimal reproduction of your use case? I feel like there should be a better approach rather than modifying the
If performance is a concern and you're unable to change the merge priority/order within the project, wouldn't it be possible to use |
Hello, I added this code to provide users facing this situation with more options: whether to replace the existing message on the i18n instance with the passed message.
And this way of writing can keep the function calls in the vue-i18n npm package unaffected.
The background reason is that I have an npm package and a Vue3 code base. When app.use this npm package, I passed the i18n instance of the Vue3 code base to the install function of the npm package, and then called mergeLocaleMessage, which caused the message of the npm package to overwrite the value of the same key in the Vue3 code base, but I hope that the message in the Vue3 code base has a higher priority, so I thought of this way.
I hope it can be adopted, thank you.