yassinedoghri / astro-i18next

An astro integration of i18next + some utility components to help you translate your astro websites!
https://astro-i18next.yassinedoghri.com
MIT License
501 stars 37 forks source link

Cannot run astro-i18next on StackBlitz #21

Closed Kyaw-Thiha closed 2 years ago

Kyaw-Thiha commented 2 years ago

I am receiving errors when trying to yarn run astro with astro-i18next attached. As soon as I take out astro-i18next from astro.config.mjs integrations, everything works fine.

Stack Blitz Link

Error Message

image

astro.config.js

import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
import sitemap from '@astrojs/sitemap';
import astroI18next from 'astro-i18next';

// https://astro.build/config
export default defineConfig({
  experimental: {
    integrations: true,
  },
  integrations: [tailwind(), sitemap(), astroI18next()],
}); 

astro-i18next.config.ts

/** @type {import('astro-i18next').AstroI18nextConfig} */
export default {
  defaultLanguage: 'en',
  supportedLanguages: ['en'],
  i18next: {
    // debug is convenient during development to check for missing keys
    debug: true,
    initImmediate: false,
    backend: {
      loadPath: './src/locales/{{lng}}.json',
    },
  },
  i18nextPlugins: { fsBackend: 'i18next-fs-backend' },
};

package.json

{
  "name": "@example/basics",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "devDependencies": {
    "@astrojs/sitemap": "^1.0.0",
    "@astrojs/tailwind": "^1.0.0",
    "astro": "^1.0.7",
    "astro-i18next": "^1.0.0-beta.4",
    "i18next-fs-backend": "^1.1.5"
  }
}
yassinedoghri commented 2 years ago

Thanks for reporting the issue!

Weirdly enough, changing the config file from .ts to .mjs worked... Here's the stackblitz.

I have no clue why though, probably a problem from stackblitz as I have a working example with a typescript config: https://github.com/ad-aures/castopod.org

Kyaw-Thiha commented 2 years ago

Thank you for the reply. It works in mine too once the config file is changed to .mjs .