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

Doesn't work with nested routes? #135

Closed
kristianhnielsen opened this issue Mar 5, 2023 · 11 comments
Closed

Doesn't work with nested routes? #135

kristianhnielsen opened this issue Mar 5, 2023 · 11 comments
Labels
bug Something isn't working help wanted Extra attention is needed released on @beta

Comments

@kristianhnielsen
Copy link

kristianhnielsen commented Mar 5, 2023

Describe the bug

It seems that it cannot read/generate routes nested in the pages/ dir. I couldn't find any examples or documentation on this.
It generates all other routes directly located in pages/ correctly.
Any solution or docs reference is much appreciated.

To Reproduce

I used the exampes/basic, added a hello folder with an index.astro, and run npx astro-i18next generate.

PS C:\Users\Kristian\Web Development\astro-i18next\examples\basics> npx astro-i18next generate
🧪 Localized .astro pages were generated successfully, it took 17ms!
node:fs:600
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open './src/pages/llo\index.astro'
    at Object.openSync (node:fs:600:3)
    at Object.readFileSync (node:fs:468:35)
    at file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:352:1236
    at Array.forEach (<anonymous>)
    at yw (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:352:1162)
    at Object.handler (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:353:57096) 
    at file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:28084
    at $v (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:24145)
    at IC.handleValidationAndGetResult (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:28067)
    at file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:28635 {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: './src/pages/llo\\index.astro'
}

Context (please complete the following information):

  • astro-i18next version: 1.0.0-beta.18
  • astro version: 2.0.15
  • OS: Windows 11
@kristianhnielsen kristianhnielsen changed the title showDefaultLocale preventing nested routes Doesn't work with nested routes? Mar 5, 2023
@yassinedoghri yassinedoghri added the bug Something isn't working label Mar 5, 2023
@yassinedoghri
Copy link
Owner

Hey, this is probably because of Windows. In the error, it shows a wrong path: ./src/pages/llo\\index.astro. I'll see it fixed.

yassinedoghri pushed a commit that referenced this issue Mar 5, 2023
# [1.0.0-beta.19](v1.0.0-beta.18...v1.0.0-beta.19) (2023-03-05)

### Bug Fixes

* add levels to relative path in script tag ([1203d42](1203d42)), closes [#129](#129)
* use unjs/pathe to resolve generated localized files paths across OS ([da80a8d](da80a8d)), closes [#135](#135)

### Reverts

* **i18next-peer:** reset i18next as package dependency ([7906e19](7906e19)), closes [#131](#131)
@github-actions
Copy link

github-actions bot commented Mar 5, 2023

🎉 This issue has been resolved in version 1.0.0-beta.19 🎉

The release is available on:

Your semantic-release bot 📦🚀

@kristianhnielsen
Copy link
Author

Hi, appreciate the quick reply, however I still get the same error after using 1.0.0-beta.19 on Windows.

Error message:

node:fs:600
  handleErrorFromBinding(ctx);
  ^

Error: ENOENT: no such file or directory, open './src/pages/llo\index.astro'
    at Object.openSync (node:fs:600:3)
    at Object.readFileSync (node:fs:468:35)
    at file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:352:1308
    at Array.forEach (<anonymous>)
    at zI (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:352:1234)
    at Object.handler (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:352:2668)
    at file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:28069
    at Lv (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:24130)
    at aC.handleValidationAndGetResult (file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:28052)
    at file:///C:/Users/Kristian/Web%20Development/astro-i18next/examples/basics/node_modules/astro-i18next/dist/cli/index.js:286:28620 {
  errno: -4058,
  syscall: 'open',
  code: 'ENOENT',
  path: './src/pages/llo\\index.astro'
}

Node.js v18.12.0

@yassinedoghri
Copy link
Owner

Sorry, I cannot test on Windows so I fixed what I thought was the issue. But I guess I was wrong. I'm reopening, hopefully I can understand what's going on soon.

Would be great if anyone could help debug this on Windows.

@yassinedoghri yassinedoghri reopened this Mar 6, 2023
@yassinedoghri yassinedoghri added help wanted Extra attention is needed and removed released on @beta labels Mar 6, 2023
@hailetrung
Copy link

hailetrung commented Mar 8, 2023

@yassinedoghri
When i debug, I found that getAstroPagesPath in utils.ts output was wrong for windows. it delete 2 first letters, maybe this info help :)

for more details, its the line 134 .withRelativePaths() seems not working correctly in windows, withBasePaths() or withFullPaths() still working correctly, you may want to try get the relative path from them. (for Windows)

image
which should be
image

@yassinedoghri
Copy link
Owner

@hailetrung Thank you for debugging, it's super useful!

I've patched it using withFullPaths() instead as you suggested, but couldn't test on Windows. Hopefully it works! 🤞

yassinedoghri added a commit that referenced this issue Mar 9, 2023
yassinedoghri pushed a commit that referenced this issue Mar 9, 2023
# [1.0.0-beta.20](v1.0.0-beta.19...v1.0.0-beta.20) (2023-03-09)

### Bug Fixes

* add missing `script` to regex in resolveRelativePathsLevel ([9288efe](9288efe)), closes [#129](#129)
* get astro pages' full paths using fdir's withFullPaths instead of withRelativePaths ([92a5178](92a5178)), closes [#135](#135)

### Features

* make base path for i18next resources configurable ([4e4b057](4e4b057))
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

🎉 This issue has been resolved in version 1.0.0-beta.20 🎉

The release is available on:

Your semantic-release bot 📦🚀

@yassinedoghri
Copy link
Owner

@kristianhnielsen @hailetrung Please let me know if it works on beta.20

@hailetrung
Copy link

@yassinedoghri
Hi, I believe we need to resolve astroFileFullPath as well, and already tested local on Windows 11.
code

the debug result was:
image

yassinedoghri pushed a commit that referenced this issue Mar 9, 2023
# [1.0.0-beta.21](v1.0.0-beta.20...v1.0.0-beta.21) (2023-03-09)

### Bug Fixes

* resolve astroFileFullPath to extract relative astroFilePath on Windows ([c23cd27](c23cd27)), closes [#135](#135)
@github-actions
Copy link

github-actions bot commented Mar 9, 2023

🎉 This issue has been resolved in version 1.0.0-beta.21 🎉

The release is available on:

Your semantic-release bot 📦🚀

@yassinedoghri
Copy link
Owner

@hailetrung Should be good in beta.21 then 🤞, thank you!

AliLee0923 pushed a commit to AliLee0923/astro-i18N that referenced this issue Dec 2, 2023
# [1.0.0-beta.19](yassinedoghri/astro-i18next@v1.0.0-beta.18...v1.0.0-beta.19) (2023-03-05)

### Bug Fixes

* add levels to relative path in script tag ([1203d42](yassinedoghri/astro-i18next@1203d42)), closes [#129](yassinedoghri/astro-i18next#129)
* use unjs/pathe to resolve generated localized files paths across OS ([da80a8d](yassinedoghri/astro-i18next@da80a8d)), closes [#135](yassinedoghri/astro-i18next#135)

### Reverts

* **i18next-peer:** reset i18next as package dependency ([7906e19](yassinedoghri/astro-i18next@7906e19)), closes [#131](yassinedoghri/astro-i18next#131)
AliLee0923 pushed a commit to AliLee0923/astro-i18N that referenced this issue Dec 2, 2023
# [1.0.0-beta.20](yassinedoghri/astro-i18next@v1.0.0-beta.19...v1.0.0-beta.20) (2023-03-09)

### Bug Fixes

* add missing `script` to regex in resolveRelativePathsLevel ([9288efe](yassinedoghri/astro-i18next@9288efe)), closes [#129](yassinedoghri/astro-i18next#129)
* get astro pages' full paths using fdir's withFullPaths instead of withRelativePaths ([92a5178](yassinedoghri/astro-i18next@92a5178)), closes [#135](yassinedoghri/astro-i18next#135)

### Features

* make base path for i18next resources configurable ([4e4b057](yassinedoghri/astro-i18next@4e4b057))
AliLee0923 pushed a commit to AliLee0923/astro-i18N that referenced this issue Dec 2, 2023
# [1.0.0-beta.21](yassinedoghri/astro-i18next@v1.0.0-beta.20...v1.0.0-beta.21) (2023-03-09)

### Bug Fixes

* resolve astroFileFullPath to extract relative astroFilePath on Windows ([c23cd27](yassinedoghri/astro-i18next@c23cd27)), closes [#135](yassinedoghri/astro-i18next#135)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed released on @beta
Projects
None yet
Development

No branches or pull requests

3 participants