Routes

Choose which pages have a URL in every language.

Syntax

$ vela i18n routes [--all]

A page is translated as soon as its strings are, but it only gets a URL of its own in each language, such as /es/about, when its path is listed under url.patterns in wuchale.config.js. For a path that is not listed:

  • links to it stay in the default language, so a visitor reading in Spanish who follows one lands on the English page
  • the page answers 404 under a locale prefix: /es/about is not found

vela enable i18n starts the list with / alone. This command shows the project’s pages in a multi-select and writes your answer to url.patterns, then extracts so the change takes effect.

What is offered

Every route with a page, read from src/routes the way SvelteKit reads it. Endpoints are left out. Each page is offered as the pattern that matches it:

RoutePattern
/about/about
/blog/[slug]/blog/*
/docs/[...path]/docs/**
  • Pages already listed start checked, and so do the other public pages.
  • The sign-in pages and the pages under (app) start unchecked. Check them if the signed-in part of the app is translated too.
  • Unchecking a listed page removes it from the list.
  • A page that a broader pattern already matches, as /blog/** matches /blog/hello, is reported and not offered again.

Anything else in url.patterns, such as an entry you added by hand, is left as it is.

Broad patterns

A route with a parameter as its first segment, such as /[slug] or /[...rest], needs a pattern that starts with a wildcard: /* or /**. Such a pattern also matches files in static/, so asset("/logo.png") and links to those files would point at /es/logo.png, which does not exist. These patterns start unchecked and say so. If you check one, link to static files with full URLs or keep them out of translated components.

Options

  • --all - Add every page without asking. Broad patterns are still left out, with a note naming them.

Without a terminal to ask on, as in CI, the command needs --all; without it, it stops and says so.

Run it again whenever you add a page.