Skip to content
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

Update content of /api/* #56

Closed
BjoernRave opened this issue Feb 14, 2020 · 13 comments
Closed

Update content of /api/* #56

BjoernRave opened this issue Feb 14, 2020 · 13 comments
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@BjoernRave
Copy link
Contributor

BjoernRave commented Feb 14, 2020

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

@aralroca
Copy link
Owner

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.

@BjoernRave
Copy link
Contributor Author

BjoernRave commented Feb 14, 2020

@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

@aralroca aralroca added this to the 1.0.0 milestone Feb 17, 2020
@aralroca aralroca added enhancement New feature or request help wanted Extra attention is needed Needs investigation Requires time to do some research labels Feb 17, 2020
@aralroca
Copy link
Owner

aralroca commented Apr 2, 2020

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 🙂

@aralroca aralroca modified the milestones: 1.0.0, 0.15.0 Apr 2, 2020
@aralroca aralroca removed Needs investigation Requires time to do some research help wanted Extra attention is needed labels Apr 2, 2020
@aralroca aralroca modified the milestones: 0.15.0, 0.16.0 Apr 18, 2020
@bilLkarkariy
Copy link

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)
     }
   }
 }

@aralroca
Copy link
Owner

@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.

@aralroca
Copy link
Owner

@bilLkarkariy your code is introduced into the code base by #138, it's available on >0.15.1

@bilLkarkariy
Copy link

@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 !!!

@aralroca aralroca modified the milestones: 0.16.0, 0.17.0 May 7, 2020
@aralroca aralroca modified the milestones: 0.17.0, 0.18.0 May 29, 2020
@aralroca aralroca modified the milestones: 0.18.0, 0.19.0, 0.20.0 Oct 23, 2020
@aralroca aralroca self-assigned this Nov 3, 2020
@aralroca
Copy link
Owner

aralroca commented Nov 3, 2020

This will be automatically fixed after #303 (1.0.0)

@aralroca aralroca removed this from the 0.20.0 milestone Nov 3, 2020
@aralroca aralroca added this to the 1.0.0 milestone Nov 3, 2020
@aralroca
Copy link
Owner

aralroca commented Dec 1, 2020

Closing this. Already implemented on 1.0.0-canary.1. The 1.0 will be released approximately 1-2 weeks. 😊

@bilLkarkariy
Copy link

bilLkarkariy commented Jun 10, 2022

@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.

Hi @aralroca !
I know it's been a while and I did not contribute as much as all other contributors, but may I ask if you can add me for this one as a contributor?

Thanks!

@aralroca
Copy link
Owner

@bilLkarkariy yes, you are welcome :) ! Please @all-contributors add @bilLkarkariy for code

@allcontributors
Copy link
Contributor

@aralroca

I've put up a pull request to add @bilLkarkariy! 🎉

@aralroca
Copy link
Owner

@bilLkarkariy already added in canary branch: https://github.com/vinissimus/next-translate/tree/canary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants