-
Notifications
You must be signed in to change notification settings - Fork 37
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
translation.json not hot reloading. need to restart astro dev #167
Comments
Here's a small integrations that might help:
import { fileURLToPath } from "node:url";
import glob from "fast-glob";
export default function astroI18nextReloader() {
return {
name: "astro-i18next-reloader",
hooks: {
"astro:config:setup": async ({ command, config, addWatchFile }) => {
if (command !== "dev") return;
await glob(`**/*.json`, {
cwd: fileURLToPath(config.publicDir),
}).then((f) =>
f.map((file) => {
addWatchFile(new URL(`./${file}`, config.publicDir));
})
);
},
},
};
} eg: import { defineConfig } from "astro/config";
import astroI18next from "astro-i18next";
import astroI18nextReloader from "./astro-i18next-reloader";
// https://astro.build/config
export default defineConfig({
integrations: [
astroI18next(),
astroI18nextReloader(),
],
}); It's not perfect but it's enough for me so I thought I'd share. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This probably isn't a bug, just need some help, in case I may have set things up wrong. I currently have set up i18n according to the suggested recommendations in the README.md (A file I have is
public/locales/en/translation.json
). I'm using astrowind as my starter code, and it seems that whenever I make a change intranslation.json
the change is not reflected in the website even though I get this message[astro] update /public/locales/en/translation.json
.To see the changes I need to kill and rerun
pnpm dev
.I'm using "astro-i18next": "1.0.0-beta.21",
The text was updated successfully, but these errors were encountered: