Closed sshmaxime closed 12 months ago
Please follow the issue template, it's here for a reason.
Are you talking about the defaultLocale
option in createI18nMiddleware
?`
Yes. I think the default schema is taken from the first element array in the locales
array, rather than being taken from the defaultLocale
.
That's not how it works. By default (only if the user hasn't yet visited the website), the locale is resolved from the Accept-Language
header. You can override this behavior by using the resolveLocaleFromRequest
option if you don't want to use this logic by default.
See the code for the middleware here: https://github.com/QuiiBz/next-international/blob/main/packages/next-international/src/app/middleware/index.ts
I meant from the developer perspective not from the end user. Typescript wise, the t("hello")
is typed depending on the locale file of the first element in the locales
array and not from the defaultLocale
. Does that make more sense ?
Oh okay, I didn't understand correctly. It's because of this line: https://github.com/QuiiBz/next-international/blob/282c84ebe8362be9823adcb3d0a868bcc4c2b65c/packages/international-types/index.ts#L76
It's not possible to get the defaultLocale
defined in the middleware from createI18nServer
/createI18nClient
because these are completely different and not related. The only way would be to introduce a new defaultLocale
option inside createI18nServer
/createI18nClient
that would only be useful for this purpose.
I don't think introducing this option is necessary, since an easier fix would be to move the default locale as the first item in the locales objects.
Oh alright, well fair enough then. Might be worth mentioning it in the docs then. Thanks for the fast replies 🙏
Title.