refactor/i18n/intlayer #73
No reviewers
Labels
No labels
dependencies
automerge
bug
dependencies
duplicate
help wanted
invalid
lang
rust
migrations
opencode
question
security
type
documentation
type
enhancement
type
maintenance
type
refactor
vulnerability
wontfix
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Reference
Personal/martials.no!73
Loading…
Reference in a new issue
No description provided.
Delete branch "refactor/i18n/intlayer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Review Summary
This PR migrates i18n from paraglide-js to intlayer. The overall structure is sound and follows intlayer's documented Astro patterns: colocated
*.content.tsdictionaries,prefix-no-defaultrouting viasrc/pages/[...locale]/..., andgetLocalizedUrl/getLocaleFromPathhelpers used consistently. Key matching betweengetIntlayer(key, locale)calls and dictionary files looks correct.However, I found one likely runtime-breaking bug and a couple of behavioral regressions that should be addressed before merge:
Astro.originPathname) — this is the most serious issue. intlayer's own Astro docs useAstro.url.pathname;Astro.originPathnameis not a standard Astro global. If it isundefined,getPathWithoutLocale(undefined)will throw at runtime and crash the breadcrumb (rendered on every page viaLayout.astro).[...locale]routing regresses 404s — becausegetCurrentLocalefalls back to the default locale and the rest-param route matches unknown single-segment paths, any bogus URL like/foo(or/foo/projects/x) now renders localized content instead of returning a 404. The old folder-based + middleware setup 404'd these.vite.ssr.externalapplied to all builds, not just dev — the comment justifies the externals with a dev-mode module-runner issue, butssr.externalalso affects the production build; combined withnoExternal: trueit means the intlayer CJS packages must be resolvable fromnode_modulesat runtime, which can break a bundled/standalone deployment.i18nconfig and not exportinggetStaticPathsfrom the[...locale]pages means@astrojs/sitemapcan no longer enumerate thenb/envariants or emit hreflang alternates.Net: the migration is well-executed but the breadcrumb crash and the silent 404 regression need fixes.
*🤖 Review by opencode (opencode/hy3-free) — verdict: changes
Code review findings from opencode.
@ -29,22 +25,28 @@ export default defineConfig({sitemap(),@ -47,1 +40,4 @@noExternal: true,// Intlayer's file watcher (fast-glob/picomatch) is CJS-only and breaks// when routed through Vite's dev-mode SSR module runner; keep it external.external: [@ -4,3 +4,3 @@import type { NavLink } from "@/utils/linking"const pathname = deLocalizeHref(Astro.originPathname)const pathname = getPathWithoutLocale(Astro.originPathname)@ -0,0 +5,4 @@import { getCurrentLocale } from "@/utils/locale"import "@/styles/global.css"const locale = getCurrentLocale(Astro.url.pathname)@ -0,0 +5,4 @@* default locale when the path doesn't resolve to a known locale.*/export function getCurrentLocale(pathname: string): LocalesValues {return getLocaleFromPath(pathname) ?? defaultLocale8fb5117fb6c358d665ad