Can be used to translate hardcoded texts in your theme, using locale files. It expects that you put a .yml
(YAML) file for each language of your site in the folder locales
. So if your site support dutch and english, you should have the following files:
locales/nl.yml locales/en.yml |
These files can then contain translations in an arbitrary structure. For example:
locales/nl.yml
footer: heading: "Welkom bij de footer" served_by_plate: "Deze website wordt geserveerd door Plate" contacts: phone: "Telefoon" email: "Email" |
locales/en.yml
footer: heading: "Welcome to the footer" served_by_plate: "This site is served by Plate" contacts: phone: "Phone" email: "Email" |
When these files are in place, you can use the translate
filter as follows.
On the dutch version of the site:
Input:
{{ "footer.heading" | translate }} {{ "footer.contacts.phone" | translate }} |
Output:
Welkom bij de footer Telefoon |
On the english version of the site:
Input:
{{ "footer.heading" | translate }} {{ "footer.contacts.phone" | translate }} |
Output:
Welcome to the footer Phone |