Documentation

Language switcher

The switcher is what lets visitors change language. It is configured in Translations → Switcher. It only appears when there is at least one target language.

Mode (Where it appears)

ModeWhat it does
Automatic (default)Appears on its own, floating, without touching the theme. Pick the corner in Position: bottom right, bottom left, top right or top left.
ManualPlace it wherever you want, with the block, a menu item, the shortcode or the PHP function (see below).
OffIt does not appear.

In automatic mode, if you place a switcher by hand on a page, the floating one leaves that page — there are never two.

The floating switcher also appears in the cart and the checkout. Someone who reaches the cart in the wrong language needs a way back to theirs, precisely when they are spending money.

Shape

Each shape is previewed in the panel with your site’s languages.

ShapeWhen to use it
ListSide by side, everything visible. Scrolls horizontally on its own if it does not fit.
ColumnOne per line. For footers and narrow sidebars.
MenuOpens with a click. Takes the space of a single language.
System boxThe system’s select box. On phones it opens the native wheel, easier to hit with a finger.

How it reads

  • Flags — show a flag before the name. They are drawn as SVG inside the page, only for your site’s languages, with no images and no requests, and look the same on every system (Windows has no emoji flags and showed the letters PT instead). The System box keeps emoji flags, because an option can only hold text. A language whose code includes no country (e.g. fr instead of fr_FR) gets no flag — a country is not a language.
  • Name or code — English, Español or EN, ES.
  • Suggest the language of the visitor — see The language suggestion bar.

Appearance

With a live preview alongside:

  • Box — background, border, border on hover.
  • Languages — text, background and text on hover, background and text of the current language.
  • Shape — text size, rounded corners, shadow.
  • Reset to default — goes back to the original colours.

If a text colour falls below a 4.5:1 contrast ratio (the minimum of the WCAG AA accessibility standard), the panel warns you. It warns, it does not prevent.

Placing it by hand

These work in all three modes.

In the block editor (pages, posts and the Site Editor): the Language Switcher block. It also goes inside the Navigation block, next to the header links: select the Navigation block, press +, then Browse all, and search for “Language”. Its sidebar picks the shape, name or code, and flags; whatever is left on As in Translations → Switcher follows the Switcher tab.

In a classic menu (Appearance → Menus, in themes that are not block themes): in the Language switcher box, tick Languages and click Add to Menu. On the site, the item becomes one link per language, to the same page, drawn by the theme like the other items. With the Menu and System box shapes, the current language stays in the menu and the others go in a submenu; in a single-level menu (like many footer menus) they sit side by side. If the box does not show, turn it on in Screen Options, at the top. In the Customizer, a custom link with the address #pht-switcher does the same.

In content or a widget:

[pht_switcher]

Shortcode options:

  • show_label="no" — shows only the code instead of the name;
  • class="my-class" — adds a CSS class.

In a theme template (usually header.php):

<?php pht_switcher(); ?>

Customising with CSS

The switcher uses about 4 KB of CSS, only on the pages where it appears, and zero JavaScript in three of the four shapes. Every appearance option is a CSS variable on .pht-switcher (--pht-bg, --pht-fg, --pht-hover, --pht-radius…), so a theme can redefine them without !important.


The language suggestion bar

Someone who reaches the site in a language that is not their browser’s sees a small bar at the top offering the version in their language.

  • It suggests, it does not redirect. Redirecting by browser language breaks the page cache, and Google advises against it.
  • It appears only once. Choosing or closing answers for good.
  • It is turned on and off in Switcher → Suggest the language of the visitor. It is on by default.

Browser automatic translation

On pages already translated by the plugin, Chrome and other browsers stop offering “Translate this page” — their translation on top of ours would give worse text. In the source language the offer stays active: that is how a foreign visitor discovers the site exists in their language.

Publish.
Read it in
every language.

30,000 characters, one site, no card. The key arrives by email after checkout.