-
-
Notifications
You must be signed in to change notification settings - Fork 483
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: project relative layer locale resolution #2290
feat: project relative layer locale resolution #2290
Conversation
b891fc9
to
ede2c9b
Compare
ede2c9b
to
39c0075
Compare
e764676
to
17500fa
Compare
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.
Thanks!
I got about importance note!
LGTM!
Does this change anything about the content I edited in #2268? Like, do the docs need an update? |
@dargmuesli |
* test: add `overrides` property for overriding project layer options in tests * feat: relative locale resolution * feat: validate layer options * test: fix incorrect test fixtures * fix: use defu to merge inline options * refactor: remove unused `langDir`
π Linked issue
#2206
β Type of change
These changes fix some unintuitive behaviors we have regarding layer support, it could be seen as a bug fix or feature enhancement.
π Description
At this moment projects are required to do some configuring to be able to make use of extended i18n layers. All locale files are resolved relative to the main project's
langDir
so the directory has to exist and be defined ati18n.langDir
, which in turn requiresi18n.locales
to containLocaleObject
entries. (see related issue discussion and related PR discussion)This PR changes the way the locales are resolved by looping through all layers (project and extended) and resolving all locale files relative to the main project, which should make extending i18n layers easier.
I believe this may make some breaking edge cases possible, I still need to test what happens when mixingThe final merged value oflazy
and nonlazy
layers or mixing layers withstring
locales vsLocaleObject
locales.lazy
is used to treat all provided locales as either lazy or not, this seems to work fine.Extending a project's
i18n
config with locales and messages is getting easier and easier, should we think of ways for projects to filter out locales as well?I have added a workaround/hack to be able to properly test our layer implementation, I did this by changing the
setup
function inside@nuxt/test-utils
included in this repo (specs/utils
). The changes made to the test-utils can be removed, but we will have to be mindful to use the addedoverrides
property to set project layer configurations.The
@nuxt/test-utils
package does not applynuxtConfig
overrides to the project/first layer (nuxt.options._layers[0]
), overrides are only applied to the fully merged options. The layer implementation intentionally ignores merged options as files need to be handled/resolved per layer. To work around this I have added anoverrides
key, essentially implementing our own override approach, which is handled/applied by the module itself. if there is a better way to do this please let me know.Some tests had to be changed as the layer implementation incorrectly allowed some broken configurations. Also, the
gen.test.ts
unit tests results are now technically faulty as thelangDir
locale paths are not resolved insidegen.ts
but beforehand.π Checklist