Skip to content

feat: i18n URL structure, language detection, layout width fix#2953

Open
immortal71 wants to merge 16 commits into
OWASP:masterfrom
immortal71:feat/i18n-url-structure-layout-fix
Open

feat: i18n URL structure, language detection, layout width fix#2953
immortal71 wants to merge 16 commits into
OWASP:masterfrom
immortal71:feat/i18n-url-structure-layout-fix

Conversation

@immortal71
Copy link
Copy Markdown
Contributor

@immortal71 immortal71 commented May 10, 2026

Summary

This PR is part of the redesign for cornucopia.owasp.org (Issue #2194).

Changes

  • Removed duplicate i18n library (kept the one actively used)
  • Fixed content width locked at 60% — now responsive
  • Added /en/ /es/ /uk/ URL prefix structure
  • Added browser language detection in hooks.server.js (defaults to English)
  • Updated languagePicker to navigate with correct lang prefix in URL
  • Updated svelte.config.js prerender entries for all language routes

Testing

  • Tested /en/, /es/, /uk/ routes load correctly
  • Verified language switching via languagePicker works
  • Confirmed existing translations still load

Related Issue

Closes #2194

Notes

open for team review before merging

@immortal71 immortal71 force-pushed the feat/i18n-url-structure-layout-fix branch from 73bcb35 to ad181c2 Compare May 10, 2026 04:02
@immortal71 immortal71 marked this pull request as ready for review May 13, 2026 06:59
Copilot AI review requested due to automatic review settings May 13, 2026 06:59
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the cornucopia.owasp.org SvelteKit site to support language-prefixed URLs (e.g., /en/, /es/, /uk/), adds server-side browser language detection with redirects to the prefixed structure, fixes a layout width constraint to be responsive, and removes an unused i18n dependency as part of the redesign work for Issue #2194.

Changes:

  • Add language-prefixed routing via hooks.server.js redirects and hooks.js reroute.
  • Update UI routing behavior (language picker) and improve layout responsiveness.
  • Update static prerender configuration and remove the unused svelte-i18n dependency.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
cornucopia.owasp.org/svelte.config.js Adjusts adapter-static fallback and adds prerender entries for language-prefixed routes.
cornucopia.owasp.org/src/routes/+layout.svelte Makes the main content container responsive (full width with max-width + padding).
cornucopia.owasp.org/src/routes/[lang]/[...path]/+server.js Adds a language-prefixed catch-all endpoint intended to proxy requests to non-prefixed routes.
cornucopia.owasp.org/src/lib/components/languagePicker.svelte Switches language navigation to goto() and rewrites URLs to include the language prefix.
cornucopia.owasp.org/src/hooks.server.js Implements language-prefix detection and Accept-Language based redirect to /<lang>/....
cornucopia.owasp.org/src/hooks.js Adds reroute() to strip the language prefix for route matching.
cornucopia.owasp.org/pnpm-lock.yaml Removes lock entries related to the removed svelte-i18n dependency (and associated transitive deps).
cornucopia.owasp.org/package.json Removes svelte-i18n from dependencies.
Files not reviewed (1)
  • cornucopia.owasp.org/pnpm-lock.yaml: Language not supported

Comment on lines +18 to +19
pathname.startsWith('/cards') ||
pathname.startsWith('/card') ||
Comment thread cornucopia.owasp.org/src/hooks.server.js Outdated
Comment thread cornucopia.owasp.org/svelte.config.js Outdated
Comment thread cornucopia.owasp.org/src/lib/components/languagePicker.svelte
@Adarshkumar0509
Copy link
Copy Markdown
Contributor

hii @immortal71 can you resolve the conflicts so we can get review from sydseter.

@immortal71
Copy link
Copy Markdown
Contributor Author

@Adarshkumar0509 well conflict is resolved, there is few suggestions that need to be implemented and test is failing it need fix that, give me time I can only those fix in proper device !!

Comment thread cornucopia.owasp.org/svelte.config.js Outdated
entries: [
'/',
'/en/',
'/es/',
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets' not route to the spanish version for now.

Comment thread cornucopia.owasp.org/svelte.config.js Outdated
Comment thread cornucopia.owasp.org/src/hooks.server.js Outdated
Comment thread cornucopia.owasp.org/src/hooks.js
Comment thread cornucopia.owasp.org/src/routes/[lang]/[...path]/+server.js Outdated
immortal71 and others added 3 commits May 21, 2026 19:42
- Remove /es/ and /es/about from svelte.config.js prerender entries
- Revert fallback from 'error.html' back to '/error'
- Remove 'es' from SUPPORTED_LANGS in [lang]/[...path]/+server.js
- Remove 'es' from hooks.js reroute regex
- Remove 'es' from hooks.server.js supportedLangs and pathMatch regex

Co-authored-by: sydseter <sydseter@users.noreply.github.com>
@immortal71
Copy link
Copy Markdown
Contributor Author

@Adarshkumar0509 done

@immortal71
Copy link
Copy Markdown
Contributor Author

@sydseter this is ready for review

@sydseter
Copy link
Copy Markdown
Collaborator

There are some issues:

cd cornucopia.owasp.org
pnpm install
npm install -g serve
serve build

Open http://localhost:3000/uk,

Open http://localhost:3000/cards

No card data is loaded.

Skjermbilde 2026-05-29 144217

The css is also strange:

Skjermbilde 2026-05-29 143334 Skjermbilde 2026-05-29 144114

Copy link
Copy Markdown
Collaborator

@sydseter sydseter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at my comment above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Redesign for cornucopia.owasp.org

4 participants