-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Custom 404 page - Cannot read properties of undefined (reading 'translations') #36
Comments
After some more trying to figure it out, I've narrowed it down to the error originating somewhere from the BaseLayout.astro in the custom 404 pages. ---
// import some other stuff
import { getLocale} from "i18n:astro";
const locale = getLocale();
---
<html lang={locale}>
// markup
</html> It looks like getLocale() can't be accessed. I've started using However, the 404 pages do not work as expected anymore:
|
Thanks for opening an issue! Tbh I don't have time to debug this nor fix it, so feel free to use workarounds and/or submit a fix if you find one |
Hi Florian, |
Sure let's keep it open! I'll label it correctly now |
Hi, Hi everyone, Now I believe that the issue boils down to: is a custom 404 route supposed to return errors in dev mode (while working fine in production)? There's also some chatter on this Starlight thread that could be related to this issue. To summarize, middleware is intentionally not run in dev mode on Astro In the minimal repros below, I have followed the installation steps laid out in the integration's docs.
import { defineConfig } from "astro/config"
import i18n from "@astrolicious/i18n"
export default defineConfig({
integrations: [
i18n({
defaultLocale: "en",
locales: ["en", "fr"],
client: {
data: true,
// paths: true,
// translations
}
})
]
})
Now, when running
Here are the repros: Thank you for your time! |
It should probably work after withastro/astro#12034 is merged, and a patch released! |
Fingers crossed :) |
The issue is now fixed on my end with an update to Astro v4.15.9. |
Hi Florian,
Hope you're well.
I have a project using your package: https://github.com/CodeStitchOfficial/Advanced-Astro-v4-i18n
1. The problem
While on dev mode, navigating to any page throws this error:
The line
at 404 (eval at instantiateModule (file:///C:/Users/user/Documents/-=%20Web%20dev%20=-/CODE/-=%20Templates%20=-/Advanced-Astro-v4-i18n/node_modules/vite/dist/node/chunks/dep-BzOvws4Y.js:52861:24), <anonymous>:19:12)
made me look into the custom 404 page.Deleting this page gets rid of the error. Good, but I want a translated 404 page lol. Also note that this error does not happen on the deployed site, where the 404 pages work perfectly.
2. My setup
Following the docs, I've set up two 404 pages as I want fully static, under
src/pages/404.astro
andsrc/pages/fr/404.astro
. I've also configured the rewrites for Netlify.I tried to narrow it down by deleting all references to
t()
orgetLocalePath()
, but I still get an error, with a different problem (reading 'data')(The repo currently shows one 404 page located in
routes/
, and I've tried the above setup in a branch)I've tried setting all client keys to true (data, paths and translations), to no avail (I don't really understand what they do to be honest)
One thing I haven't tried is using SSR in hybrid mode.
While this error does not seem to impede the deployed site, it's a hassle to deal with in development. Do you have any idea where it comes from?
thank you for your time.
The text was updated successfully, but these errors were encountered: