Developers · Pages and Layouts
Multi-Language Page
Last updated 7 November 2026
This document details the following aspects of a Multi-Language Page:
- Defaults
- Switching between languages
- Simple usage
- Arrays
- Parameterisation (variables)
- Pluralisation
Defaults
English is the default language.
If there is a
You can also set the language in
Switching between languages
You can check and set the language to switch using the following code:
{% liquid
assign language_switch_url = context.location.pathname
assign language_icon = "language-pl"
if context.session.language == "pl"
assign language_switch_url = language_switch_url | append: "?language=en"
assign language_icon = "language-en"
else
assign language_switch_url = language_switch_url | append: "?language=pl"
endif
%}
<a href="{{ language_switch_url }}" aria-label="Change language">
{%- include "svg/icons", icon: language_icon -%}
</a>Simple usage
To use the
We will use the page translation key in two languages in this example to demonstrate the mechanism.
---
slug: multilanguage
---
{{ "general.greeting" | t }}app/translations/en.yml
en:
general:
greeting: Hello, World!app/translations/pl.yml
pl:
general:
greeting: Witaj świecie!Having these two files enables you to use the
For example, opening
/multilanguage
Hello, World!/multilanguage?language=pl
Witaj świecie!Arrays
Inside YAML, it is possible to include any data structure that is usable in JSON, including arrays.
Visit json2yaml to learn how YAML will convert to JSON or vice-versa if you feel more comfortable in JSON.
You can use this feature alongside other filters to store collections in a readable form.
app/translations/en.yml
en:
general:
cars:
- Ford Mustang
- Corvette
- Gran Torinoapp/translations/jp.yml
jp:
general:
cars:
- Honda
- Subaru
- LexusExample page
{% assign cars = "general.cars" | t | to_hash %}
<ul>
{% for car in cars %}
<li>{{ car }}</li>
{% endfor %}
</ul>/multilanguage?language=en
<ul>
<li>Ford Mustang</li>
<li>Corvette</li>
<li>Gran Torino</li>
</ul>/multilanguage?language=jp
<ul>
<li>Honda</li>
<li>Subaru</li>
<li>Lexus</li>
</ul>Parameterisation (variables)
Sometimes you'll need to translate parts of a sentence but keep others (e.g. names). In these cases, some of the content should be parameterised.
The
app/translations/en.yml
en:
personal:
hello: "Hello %{name}. Take a look at my website: %{url}"app/translations/pl.yml
pl:
personal:
hello: "Cześć %{name}. Zerknij na moją stronę www: %{url}"Example page
{% liquid
assign my_name = context.params.name | default: "Pawel"
assign url = context.params.url | default: "https://example.com"
%}
{{ "personal.hello" | t: name: my_name, url: url }}/multilanguage?language=en&name=John&url=https://docs.growthgardens.com
Hello John. Take a look at my website: https://docs.growthgardens.com/multilanguage?language=pl&name=Pawel&url=https://growthgardens.io
Czesc Pawel. Zerknij na moja strone www: https://growthgardens.ioPluralisation
In many languages — including English — there are only two forms: singular and plural for a given string, e.g. "1 message" and "2 messages". Other languages (Arabic, Japanese, Russian and many more) have different grammar with additional or fewer plural forms. Thus, the
The
If you set this to your language file:
about_x_item:
one: "One item"
other: "%{count} items"Then:
{{ "about_x_item" | t: count: 12 }}
{{ "about_x_item" | t: count: 1 }}The output rendered is:
12 items
One item