DocsTheme structure & publishing
On this page

Add a language button

Let visitors read the site in another language.

Before you begin: Switch light and dark mode.

The button

Add f-language-switch to a button in your header. Put f-language-current="code" inside it to show the current language's short code, or f-language-current alone to show its name:

index.html
  • A click opens the language picker. It takes the page's colours and font, slides up from the bottom on phones, and lists each language in its own script.
  • The visitor's choice is remembered, and the same page opens in that language.
  • The button is hidden, from the first paint, on sites that offer one language. Keep it in your markup anyway: it appears as soon as the site offers more.

Where to put it

Put it where visitors look for it: in the header, next to the account or sign-in buttons, on every page. On phones keep it in the header bar next to the menu button rather than inside the menu, and leave room for the two-letter code.

Text your scripts add

Pages arrive translated. For text your own script adds, use Frontbacked.t("Saved"), which returns the translation from the theme's languages.

Continue with Style dialogs and feedback.