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

feat: merging of locale files with the same name for @intlify/unplugin-vue-i18n/messages #274

Merged
merged 3 commits into from
Nov 2, 2023
Merged

feat: merging of locale files with the same name for @intlify/unplugin-vue-i18n/messages #274

merged 3 commits into from
Nov 2, 2023

Conversation

DanielleHuisman
Copy link
Contributor

@DanielleHuisman DanielleHuisman commented Jun 19, 2023

Currently, unplugin-vue-i18n doesn't merge keys for locale files with the same name. However, this would be a useful feature to allow splitting up locales over multiple files. For example:

src/locales/user/en.yaml
src/locales/user/nl.yaml
src/locales/group/en.yaml
src/locales/group/nl.yaml
// Should include locales from all subdirectories by locale
import messages from '@intlify/unplugin-vue-i18n/messages'

This issue was also brought up for the deprecated vite-plugin-vue-i18n in #3.

This PR implements the merging behaviour. I chose to use lodash.merge to ensure the deep merging is production-ready code.

To test the new behaviour, the Vite locales were split up into two files. Without the changes to unplugin-vue-i18n/src/index.ts, the tests fail, but with the changes they pass again.

@DanielleHuisman
Copy link
Contributor Author

@kazupon any chance this can get merged soon?

Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for my late reply.
I've just reviewed!
please check it!

@kazupon
Copy link
Member

kazupon commented Oct 27, 2023

@DanielleHuisman
Thanks!

One more request, this feature is for @intlify/unplugin-vue-i18n/messages only.
so, we need to update docs (README.md)

@DanielleHuisman
Copy link
Contributor Author

One more request, this feature is for @intlify/unplugin-vue-i18n/messages only. so, we need to update docs (README.md)

I updated README.md with a minimal explanation of the merge feature.

Copy link
Member

@kazupon kazupon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well done!
Thank you so much!

@kazupon kazupon changed the title Fix merging of locale files with the same name feat: merging of locale files with the same name for @intlify/unplugin-vue-i18n/messages Nov 2, 2023
@kazupon kazupon merged commit 8d042fc into intlify:main Nov 2, 2023
3 checks passed
@DanielleHuisman DanielleHuisman deleted the fix/merge-locale-files branch November 2, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants