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
Allow function type for localePath #1593
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/isaachinman/next-i18next/26jw96b8bTAGiXYCFLEu3sdVAMRz |
2c14389
to
005997c
Compare
src/config/createConfig.ts
Outdated
if (localePath.match(/^\.?\/public\//)) { | ||
clientLocalePath = localePath.replace(/^\.?\/public/, '') | ||
} | ||
const clientLocalePath = typeof localePath === 'string' && localePath.match(/^\.?\/public\//) |
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.
Has to be const to satisfy typescript, since line 157 uses a closure.
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.
Additionally, it seems to me this stripping of /public
on the client isn't necessary, since nothing is even read on the client - I'm not totally sure though.
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.
Yeah, we can probably remove the stripping of /public
. It's a remnant of when this package used to use i18next-http-backend
by default, and used getInitialProps
, necessitating client side loading of namespaces.
Thanks @lucaslcode! Just wanted to give a heads up that I am travelling now, and probably won't be able to review this until sometime in January. Rest assured I will work with you to get this merged as soon as possible. |
Thanks for the update, no worries!
…On Tue, 28 Dec 2021, 06:07 Isaac Hinman, ***@***.***> wrote:
Thanks @lucaslcode <https://github.com/lucaslcode>! Just wanted to give a
heads up that I am travelling now, and probably won't be able to review
this until sometime in January. Rest assured I will work with you to get
this merged as soon as possible.
—
Reply to this email directly, view it on GitHub
<#1593 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHUPIP3VCHONHVHQZCSYQQTUTDPTNANCNFSM5KTAU4XA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
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 for your patience – finally had a chance to get to this.
Just a few comments to discuss a bit, but overall I am extremely impressed with both the quality of the code, and your ability to understand the wider repo.
Massive thanks for this contribution!
src/config/createConfig.ts
Outdated
if (localePath.match(/^\.?\/public\//)) { | ||
clientLocalePath = localePath.replace(/^\.?\/public/, '') | ||
} | ||
const clientLocalePath = typeof localePath === 'string' && localePath.match(/^\.?\/public\//) |
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.
Yeah, we can probably remove the stripping of /public
. It's a remnant of when this package used to use i18next-http-backend
by default, and used getInitialProps
, necessitating client side loading of namespaces.
@isaachinman thanks for the review (and the compliment 😄). I've addressed the feedback, including removing the stripping of |
Looks great @lucaslcode, thanks for all your help! Weirdly this PR is not running tests in Circle – I think it's related to a CircleCI OAuth issue a couple weeks ago. Can you try rebasing against latest |
No longer strips the '/public' directory in the client, so removed the 'env' parameter from localePath callback.
6c8a87a
to
9970283
Compare
I'll try a new PR |
Fixes #1500
See comments
Tests added
Wasn't sure how to add tests for the additional functionality - any guidance appreciated (maybe I should add tests for the error cases and that the function is correctly in the final config by calling it?)