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

BUG: Translation files cannot be found #89

Closed
demiro opened this issue Dec 14, 2022 · 2 comments
Closed

BUG: Translation files cannot be found #89

demiro opened this issue Dec 14, 2022 · 2 comments

Comments

@demiro
Copy link

demiro commented Dec 14, 2022

So, I have recently upgraded my astro packages (that were working fine before) including astro-i18next...

I moved the locales from src/locales/en.json ... to public folder as stated in gest started guide:

but when running dev, I get this error:

image

Suspect it has something to do with the "/" in front of C:\

The file is 100% there... I tried of course opening this same file with a simple node script and is working completely fine

image

my config file (astro-i18next.onfig .ts)

import type { AstroI18nextConfig } from "astro-i18next";

const config: AstroI18nextConfig = {
  defaultLocale: "en",
  locales: ["en", "es"],

  i18nextServer: {
    debug: true,
  },
  i18nextClient: {
    debug: true,
  },
};

export default config;

my node test script

import fs from "fs";

fs.readFile(
  "C:/DEVELOPMENT/xxxxx/public/locales/en/translation.json",
  "utf8",
  (err, data) => {
    if (err) {
      console.error(err);
      return;
    }
    console.log(data);
  }
);
@demiro
Copy link
Author

demiro commented Dec 14, 2022

So after playing around for a while, I found the solution... maybe this should be somewhere in your examples

O cjanged my plain config to include:

i18nextServer: {
    debug: true,
    initImmediate: false,
    backend: {
      loadPath: "./public/locales/{{lng}}/translation.json",
    },
  },
  i18nextClient: {
    debug: true,
    initImmediate: false,
    backend: {
      loadPath: "./public/locales/{{lng}}/translation.json",
    },
  },

@yassinedoghri
Copy link
Owner

Hey @demiro, thanks for the issue. As you mentioned, it's because of the leading / on Windows.

This is a duplicate of #79, so I'm closing it.

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

No branches or pull requests

2 participants