-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
i18next::backendConnector: loading namespace translation for language es failed #1609
Comments
If that error is coming from server side, the loadPath is for sure wrong. I assume you have no /locales folder in your root directory. |
@adrai I copied /locales to the root folder and got the same error. http://localhost:3000/locales/en/translation.json is fully accessible though. And nothing shows up in the network tab, so it's the server side where the issue lies. The loadPath matches the folder structure, even with the path the error lists out ('/locales/en/translation.json'). I'm really lost on this one. |
What's the output if you enter this in your shell terminal? Maybe also try with the relative path (no slash at the start):
|
@yassinedoghri maybe you can help? |
From the root project folder:
Without /
From /public
|
so just remove the slash |
Got a different error by removing the slash:
My test translation file:
|
This is a better error... Are you sure this is your original content? {
"leadForm": "Lead form"
} A minimal reproducible example would help to investigate. |
I am, yes. I left just one string specifically to help with debugging. |
does an error occur with an empty json? {} |
if you manually read that file and JSON.parse it, does it work? |
btw: based on the astro-i18next code, you might also define the loadPath like this: https://github.com/yassinedoghri/astro-i18next/blob/beta/src/index.ts#L77 |
I get the same error with an empty json. Fetching the file contents returns it correctly: |
if all this does not help, you might also console.log(data) in this file on line 98: /Users/victor/Work/Camino/astro-playground/lead-form/node_modules/i18next-fs-backend/esm/readFile.js |
console.log results from readFile.js:
Looks good... I'll try that different LoadPath definition, but I'll need to get the public path differently because config.publicDir.pathname is not available on astro-i18next.config.js |
The ending comma is the problem!!! |
The file doesn't have it anymore, I removed it a few mins ago... could it be cached somehow? |
I never used astro-i18next before... but I don't think so |
fyi: I just tested this example: https://github.com/yassinedoghri/astro-i18next/tree/beta/examples/node import type { AstroI18nextConfig } from "astro-i18next";
const config: AstroI18nextConfig = {
defaultLocale: "en",
locales: ["en", "fr"],
i18nextServer: {
debug: true,
backend: {
ns: ['translation'],
loadPath: 'public/locales/{{lng}}/{{ns}}.json',
},
},
};
export default config; And it all seems to work as expected. |
I removed the other test project I copied to test with and it worked now! The other one had the comma at the end... idk how or why but I'm thinking it was targeting that one? Idk... But it works now. Thank you so much for you help, @adrai ! |
you're welcome... but next time please open the issue in the correct repo... This issue was not really related to react-i18next... If you like i18next don鈥檛 forget to star it. Make a tweet, share the word or have a look at our https://locize.com to support the devs of this project. There are many ways to help this project 馃檹 |
@adrai Just saw the mention, sorry for being late to the party... Glad it has been resolved. |
馃悰 Bug Report
I'm getting this error, even though the file exists and is accessible as an absolute url too:
i18next::backendConnector: loading namespace translation for language en failed Error: ENOENT: no such file or directory, open '/locales/en/translation.json'
I'm using astro-i18next with Astro.
My initial config:
Project structure:
My Environment
The text was updated successfully, but these errors were encountered: