import BaseHead from '../components/BaseHead.astro'
import Header from '../components/Header.astro'
import Footer from '../components/Footer.astro'
import { SITE_TITLE, SITE_DESCRIPTION } from '../consts'
import i18next, { t } from 'i18next'
<!doctype html>
{t("landingPage.specialization")}
`
My translation files are located in :
public
└── locales # create this folder to store your translation strings
├── en
| └── translation.json
└── fr
└── translation.json
When I run npx astro-i18next generate I get this error:
/Users/andrej/.npm/_npx/507b6de246fc868e/node_modules/astro-i18n/dist/src/bin.cjs:275 .trim())}async function o(e){let{readdirSync:t}=await d.fs,{join:r}=await d.path,n=r(e,"src");if(!await N(n))return null;for(let o of t(n)){let i=r(n,o);if(Ao.test(o))return i;if(o==="middleware"&&await N(o)){for(let s of t(i))if(Po.test(o))return r(n,"middleware",s)}}return null}async function Io(e){let{readdirSync:t}=await d.fs,r=.fromRegex(Jt).assertEnding().build(),n=t(e);for(let o of n)if(await v(o)&&r.test(o))return o;return null}async function ms(e){let{join:t}=await d.path;return v(t(e,"tsconfig.json"))}var vr=vo;var xe=jr([Sr,Lr,Or,vr]),Co={[Sr.name]:Ro,[Lr.name]:So,[Or.name]:Oo,[vr.name]:ko};if(!xe.command||!Co[xe.command])throw new Y;Coxe.command;
^
ve [Error]: Invalid command.
at Object. (/Users/andrej/.npm/_npx/507b6de246fc868e/node_modules/astro-i18n/dist/src/bin.cjs:275:651)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
package.json file :
{ "name": "proud-plasma", "type": "module", "version": "0.0.1", "scripts": {
"dev": "astro dev","start": "astro dev", "build": "astro check && astro build", "preview": "astro preview", "astro": "astro", "i18n": "npx astro-i18next generate" }, "dependencies": { "@astrojs/check": "^0.5.10", "@astrojs/mdx": "^2.2.2", "@astrojs/rss": "^4.0.5", "@astrojs/sitemap": "^3.1.2", "@astrojs/tailwind": "^5.1.0", "@astrolicious/i18n": "^0.1.2", "astro": "^4.5.10", "astro-i18next": "^1.0.0-beta.21", "tailwindcss": "^3.4.3", "typescript": "^5.4.3" }, "devDependencies": { "prettier-plugin-astro": "^0.13.0" } }
;astro-i18next.config.mjs file:
/** @type {import('astro-i18next').AstroI18nextConfig} */ export default { defaultLocale: "sl", locales: ["sl", "en"], };
index.astro file:
`
import BaseHead from '../components/BaseHead.astro' import Header from '../components/Header.astro' import Footer from '../components/Footer.astro' import { SITE_TITLE, SITE_DESCRIPTION } from '../consts' import i18next, { t } from 'i18next'
<!doctype html>
{t("landingPage.specialization")}
`
My translation files are located in : public └── locales # create this folder to store your translation strings ├── en | └── translation.json └── fr └── translation.json
My Node.js version v20.9.0
I followed https://github.com/yassinedoghri/astro-i18next/tree/681e8384270b2b9ad384f83411075c9c3ee33f2d.
When I run npx astro-i18next generate I get this error:
/Users/andrej/.npm/_npx/507b6de246fc868e/node_modules/astro-i18n/dist/src/bin.cjs:275
.trim())}async function o(e){let{readdirSync:t}=await d.fs,{join:r}=await d.path,n=r(e,"src");if(!await N(n))return null;for(let o of t(n)){let i=r(n,o);if(Ao.test(o))return i;if(o==="middleware"&&await N(o)){for(let s of t(i))if(Po.test(o))return r(n,"middleware",s)}}return null}async function Io(e){let{readdirSync:t}=await d.fs,r=.fromRegex(Jt).assertEnding().build(),n=t(e);for(let o of n)if(await v(o)&&r.test(o))return o;return null}async function ms(e){let{join:t}=await d.path;return v(t(e,"tsconfig.json"))}var vr=vo;var xe=jr([Sr,Lr,Or,vr]),Co={[Sr.name]:Ro,[Lr.name]:So,[Or.name]:Oo,[vr.name]:ko};if(!xe.command||!Co[xe.command])throw new Y;Coxe.command; ^ve [Error]: Invalid command. at Object. (/Users/andrej/.npm/_npx/507b6de246fc868e/node_modules/astro-i18n/dist/src/bin.cjs:275:651)
at Module._compile (node:internal/modules/cjs/loader:1241:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
at Module.load (node:internal/modules/cjs/loader:1091:32)
at Module._load (node:internal/modules/cjs/loader:938:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
at node:internal/main/run_main_module:23:47
Node.js v20.9.0 `
Any help would be appreciated.