Language Url

By Brent Cartier

Language URL for Statamic 2


Intended to help build a language toggle for Statamic 2. For example, in a English and French site where English is the default language, you can use {{ lang_url locale="fr" }} and {{ lang_url locale="default" }} in your templates to easily switch languages of the current page:

{{ if locale == "en" }}
  <a href='{{ lang_url locale="fr" }}'>Fran├žais</a>

{{ if locale == "fr" }}
  <a href='{{ lang_url locale="default" }}'>English</a>

To Do:

Detect the default language instead of requiring "default" as the locale parameter.