Closed njarraud closed 3 years ago
@njarraud The locale
argument cannot be undefined
– the absence of locale doesn't mean we are in the default locale, it means that NextJs i18n is not enabled.
You are very quick at closing posts...
Did you even try with your simple example? You will see that it is not valid:
Hi @njarraud – I understand that NextJs has typed locale
as string | undefined
, however, this package does not accept locale
as undefined
.
Feel free to use locale as string
, or whatever you'd like!
Yes you're right but when creating a next lib we have to follow their rules. If you want just a
if (!locale) throw new Error...
in the serverSideTranslations function but it's a pain in the ass to do a global refactor to our codebase to replace all serverSideTranslations ..
@yovanoc Sure, that seems like an easy and useful PR.
Is your feature request related to a problem? Please describe.
The current code throws a typescript error for locale:
GetStaticProps locale has the type string or undefined but serverSideTranslations currently only accepts string.
Describe the solution you'd like
Maybe it would be possible to update serverSideTranslations so that if locale is undefined then it uses the default local provided in the config file.
[next-i18next v.8.1.2]