Languages

Language Switcher

Use the languages loop when the theme should render its own language switcher markup.

Basic Switcher#

phpresources/views/partials/language-switcher.php
{{ languages }}  <a href="{{ url }}" class="{{ current && 'is-current' }}" lang="{{ code }}" hreflang="{{ locale }}">    {{ if flag }}      <span aria-hidden="true">{{ flag }}</span>    {{ /if }}    <span>{{ label }}</span>  </a>{{ /languages }}

Inside the loop, each language item has:

ValueMeaning
{{ url }}The URL for that language.
{{ code }}The language URL prefix, such as en or nl.
{{ locale }}The WordPress locale, such as en_US.
{{ label }}The readable language label.
{{ flag }}The configured flag value, when used.
{{ current }}Whether this is the current language.
{{ available }}Whether translated content exists.
{{ missing }}Whether the page is falling back to default-language content.

Missing Translations#

TemplateX returns a language URL even while a translation is missing.

That keeps visitors on routes such as /nl/about/, where the page can fall back to default-language content until the translation is ready.