Skip to content
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

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

Open
DavithkbY opened this issue Sep 6, 2024 · 3 comments
Open

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

DavithkbY opened this issue Sep 6, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@DavithkbY
Copy link

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
Copy link
Member

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

@florian-lefebvre florian-lefebvre added bug Something isn't working question Further information is requested labels Sep 10, 2024
@DavithkbY
Copy link
Author

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

@florian-lefebvre florian-lefebvre removed the question Further information is requested label Sep 10, 2024
@DavithkbY
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants