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
55 stars 3 forks source link

getLocale() broken with strategy: "prefix" #35

Open DavithkbY opened 2 months ago

DavithkbY commented 2 months ago

The getLocale() is broken on the index.astro when using strategy: "prefix",

Astro config:

import { defineConfig } from "astro/config";

import liciousI18n from "@astrolicious/i18n";

// https://astro.build/config
export default defineConfig({
  integrations: [
    liciousI18n({
      defaultLocale: "en",
      strategy: "prefix",
      locales: ["en", "nl", "fr"], // must include the default locale
    }),
  ],
});

routes/index.astro :

---
import { getLocale } from "i18n:astro";

const locale = getLocale()
---

{locale}

result when navigation to /nl :

image

as you can see it's showing the locale as 'en' in the frontend, but it should be 'nl'.

when using strategy: "prefixExceptDefault" it does work as intended.

florian-lefebvre commented 2 months ago

Is it broken in 0.5.0? I wonder if the latest patch broke it

DavithkbY commented 2 months ago

Is it broken in 0.5.0? I wonder if the latest patch broke it

It's broken in 0.5.0 and also 0.5.1

DavithkbY commented 2 months ago

Furthermore, it will build the files in the right directory ex dist/nl/index.html and dist/fr/index.html but it will still build with getLocale() set to English. Making the pages all in English.