Architecture
How the Weglot plugin turns a Craft request into a translated page.
How the Weglot plugin turns a Craft request into a translated page.
This page explains what happens under the hood when a visitor requests a translated URL. You don't need to know any of this to use the plugin — it is here for developers who want to understand or debug its behavior.
Weglot serves each destination language under a path prefix, for example /fr/about for the French version of /about. These prefixed URLs are virtual: the plugin registers URL rules that map them to its own router, and no extra entries are created in Craft. The router resolves the request against your original Craft route, then the response is translated on the way out.
After the Weglot API returns the translated HTML, the plugin:
rewrites internal links (<a>, forms, canonical, next/prev, and similar) so they keep the current language prefix;
injects the hreflang alternate tags in the <head> for SEO;
injects the language switcher and Weglot's front-end script;
maps translated URL slugs both ways, so a translated slug resolves back to the right Craft entry.
The plugin caches the data it fetches from Weglot (your project options, available languages, slug maps) using Craft's cache, under keys prefixed with weglot_. This avoids calling the Weglot API on every request. If configuration changes don't appear, clearing the Craft cache forces a refresh — see Troubleshooting.