withastro / astro

The web framework for content-driven websites. ⭐️ Star to support our work!
https://astro.build
Other
46.79k stars 2.48k forks source link

Regression: astro.currentLocale always returns default locale in v4.15.8 #12291

Closed layout-ch closed 2 weeks ago

layout-ch commented 3 weeks ago

Astro Info

Astro                    v4.16.7
Node                     v22.9.0
System                   macOS (arm64)
Package Manager          npm
Output                   hybrid
Adapter                  @astrojs/vercel/serverless
Integrations             astro-icon
                         @sanity/astro
                         @astrojs/react

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

In Astro v4.15.8, Astro.currentLocale always returns the default locale regardless of the current route's language. This worked correctly in v4.8.7.

Steps to reproduce:

  1. Set up an Astro project with i18n routing
  2. Configure multiple locales with a default locale
  3. Create routes for different languages
  4. Try to access Astro.currentLocale on non-default language routes

Expected behavior:

Actual behavior:

What's the expected result?

Astro.currentLocale should return the current route's locale

Link to Minimal Reproducible Example

-

Participation

dpuscher commented 2 weeks ago

I had the same problem in 4.16.0, but it seems like it was fixed in 4.16.4 in this PR: https://github.com/withastro/astro/pull/12199