It works, that the /api routes are ignored, however the content inside there is not updated and I need to delete the folder manually.
Same applies for the _app.tsx file
It's a known problem with static sites that require the CLI to build first all the translations... This is because when you execute the yarn dev:
"dev": "next-translate && next dev",
The next-translate build is independent of next dev. So then touching the pages_ content the hotreloading is not executing again the next-translate command.
In order to work in the future with static sites + hotreloading in dev we want to replace the next-translate cli command, to a next.config.js plugin, ex: withStaticSiteTranslations(config) translating the pages in every hotreloading process.
@aralroca yea, that sound's great.
Now that you are talking about it. It was confusing me a little, that you focus so much on static sites in the docs. My site is not really static at all, but the library still works fine without having a server.
I think the end goal should be to inject the translations without the need of a cli step.
Currently there is just no good solution I know off beside this lib for internationalizing next.js in a serverless context
I think that we can easily fix this by just exporting everything from the original file instead of copy the content. I'm going to change the milestone of this to 0.15.0 in order to prioritize this 馃檪
Hi! That works nicely for me, this copy all data in api folder, all files even in subfolder :
cli/builder.js
```
function buildPageInAllLocales(pagePath, namespaces) {
const prefix = pagePath
.split('/')
.map(() => '..')
.join('/')
const rootPrefix = prefix.replace('/..', '')
// _app.js , _document.js, _error.js, /api/*
if (isNextInternal(pagePath)) {
if (pagePath.includes('/api/')) {
fs.mkdirSync(${finalPagesDir}/api, { recursive: true })
copyFolderRecursiveSync(pagePath, path.dirname(pagePath.replace(currentPagesDir, finalPagesDir)))
}
fs.copyFileSync(pagePath, pagePath.replace(currentPagesDir, finalPagesDir))
return
}
function copyFolderRecursiveSync(source, targetFolder) {
var target = path.join(targetFolder, path.basename(source));
//check if folder needs to be created
if (!fs.existsSync(targetFolder)) {
fs.mkdirSync(targetFolder);
//copy
if (!fs.lstatSync(source).isDirectory()) {
fs.copyFileSync(source, target)
}
}
}
```
@bilLkarkariy your proposal is fixing another issue than this one! This issue is about hot reloading on file changes.
By the way! Thanks for your contribution. I'm going to add it to the code base.
@bilLkarkariy your code is introduced into the code base by #138, it's available on >0.15.1
@bilLkarkariy your proposal is fixing another issue than this one! This issue is about hot reloading on file changes.
By the way! Thanks for your contribution. I'm going to add it to the code base.
Oh ! Thank you very much !!!
This will be automatically fixed after https://github.com/vinissimus/next-translate/issues/303 (1.0.0)
Closing this. Already implemented on 1.0.0-canary.1. The 1.0 will be released approximately 1-2 weeks. 馃槉
Most helpful comment
It's a known problem with static sites that require the CLI to build first all the translations... This is because when you execute the
yarn dev:The
next-translatebuild is independent ofnext dev. So then touching thepages_content the hotreloading is not executing again thenext-translatecommand.In order to work in the future with static sites + hotreloading in dev we want to replace the
next-translatecli command, to a next.config.js plugin, ex:withStaticSiteTranslations(config)translating the pages in every hotreloading process.