Locales Tag

Create links to localized content.

Examples

Iterating over locales

You can loop through in each locale to get URLs to translated versions of an entry or taxonomy term.

<ul>
{{ locales }}
  <li><a href="{{ url }}">View in {{ locale:name }}</a></li>
{{ /locales }}
</ul>

Targeting a locale

You can also specify a locale directly instead of looping through them all.

{{ locales:fr }}
    <a href="{{ url }}">View in French</a>
{{ /locales:fr }}

Parameters

id string

The ID of the content you want to localize. If left blank, the content will be taken from the context.

sort string

Sort by one of the keys in your system.yaml's locales array. (eg. name or full). If left blank, the order in the file will be maintained. Only applicable in the tag pair.

current_first boolean *true*

When true, this ensures that the current site locale will be first in the list. Only applicable in the tag pair.

Variables

Variable Type Description

locale

array

The locale data of the current iteration. Contains key, name, and full. You can use array format to access the nested value (eg. {{ locale:name }})

content data

mixed

Each piece of content being iterated through has access to all the variables inside. This includes things like title, content, url, etc.

Betterify this page on Github!