astrolicious / i18n

Yet another i18n integration for Astro with server and client utilities, type safety and translations built-in.
https://astro-i18n.netlify.app/
MIT License
56 stars 3 forks source link

Not getting translation when base is not "/" #40

Open AndresMpa opened 2 weeks ago

AndresMpa commented 2 weeks ago

Hey there, I'm trying i18n for my portafolio and I have a different base on my defineConfig so when I try to get deploy this on gh-pages I get no text or when I switch from "en" to "es" I get a 404 that redirect me to "/"

// astro.config.mjs
import { defineConfig } from "astro/config";
import liciousI18n from "@astrolicious/i18n";

export default defineConfig({
  integrations: [
    liciousI18n({
      defaultLocale: "en",
      locales: ["en", "es"],
      client: {
        data: true,
      },
    }),
  ],
  site: "https://andresmpa.github.io/",
  base: "/portafolio/",      /* <--- THIS */
});

If I make something like there's no any translation

// LocaleSwitcher.astro
  onchange="location = '/portafolio' + this.value;"

When base is "/" It works

export default defineConfig({
  /* */
  base: "/portafolio/",      /* <--- THIS */
});

Of course the switcher has to be something like this

// LocaleSwitcher.astro
  onchange="location = this.value;"
florian-lefebvre commented 1 week ago

Hey, thanks for reporting! I'm not 100% sure but it's very likely that base is not being take into account at all. Unfortunately, I'm not really available these days so it's unlikely to be fixed anytime soon. PRs welcome tho!