Hi
Thanks so much for creating and improving such a fantastic library.
I'm working on migrating an early work in progress CRA v4 app to Nextjs 10. I'm using Yarn workspaces in order to share code but i was unable to import the locale json files from the shared package.
Would it be possible to accommodate this use case ?
localesPath: "@org/common/src/locales",
Error:
Module not found: Can't resolve '../../@org/common/src/locales'
20 | Page.getInitialProps = async ctx => {
21 | const _lang = ctx.locale || ctx.router?.locale || 'ar'
> 22 | const ns0 = await import(`../../@org/common/src/locales/${_lang}/common.json`).then(m => m.default)
| ^
23 | const ns1 = await import(`../../@org/common/src/locales/${_lang}/manage-clients.json`).then(m => m.default)
24 | const _ns = { 'common': ns0, 'manage-clients': ns1 }
I can provide a repo if needed.
@ammuhaysin if you can provide a repo this would be very useful 馃檹
https://github.com/ammuhaysin/next-translate-issue
Please let me know if there is a problem with the repo.
I think the easiest way to support this is to allow the prefix package: in front.
module.exports = {
locales: ["ar", "en"],
defaultLocale: "ar",
currentPagesDir: "pages_",
finalPagesDir: "pages",
localesPath: "package:@org/common/src/locales", // this way
pages: {
"*": ["common"],
"/client/manage-clients": ["manage-clients"],
},
};
Do you find it useful? I think it's better to indicate it directly than trying to make workarounds in the builder to detect if it's a package or not. If you see it well, I implement it.
Looks good but I think adding a property (true, false) to indicate whether it's a package or not instead would be clearer.
Okay, maybe it's better, yes.
@ammuhaysin I did a prerelease 0.19.1-canary.2, if you can verify that is working fine in your case 馃憤
The 0.19.1 release will be released soon (today or tomorrow)
Looks great. Thank you.
I will test it and report back.
I tested the import and it works great.
I will continue testing and let you know if I face related problems.
I appreciate the fast responses and fixing my workspaces issue.
Great @ammuhaysin, thank you so much!