Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

How to reference to a page in a multi language setup?

Started by Muut Archive 11 years ago · 2 replies · 273 views
11 years ago

Hi! I'm tweaking ith Grav, try to better understand how to do things. Currently I have a multi language setup (en, it, pt). All pages have localized titles and slugs (example - en: Instruments/instruments; it: Strumenti/strumenti; pt: Instrumentos/instrumentos).
How can I reference the localized slug of this page? I mean, if I use {{ page.route }} and if I navigate via the menu to this page, in italian, it correctly write http://somedomain/somepage/strumenti/ but If I switch to portugues, it display http://somedomain/somepage/instruments, using the default (english) slug. What's wrong?

Cheers

11 years ago

you should be able to use the localized page route if you want to reach a specific page language version (if you know it). Alternatively there is something that every page has called the rawroute and this is basically the lang with the default file-based route appended. For example:

TXT
/en/somepage/instruments -> english version
/it/somepage/instruments -> italian version

If you have the redirect default route option set in your system.yaml, it will redirect this route to the /somepage/strumenti one.

This is basically how the lang switcher plugin works. Remember that each language is basically isolated from the others. The only way you can get to a different language version of a page is to use the rawroute. From the english page, Grav has no idea about the italian page (it has not even parsed the .md file).

This is how Grav is able to maintain performance no matter how many languages you add.

11 years ago

You are right! I missed the redirect default route in my config. This is the reason why did not work, no matter how I code... great! Kudos!!!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Deleted User, 9 years ago
0 1341 9 years ago
Archive · by Muut Archive, 9 years ago
2 928 9 years ago
Archive · by Muut Archive, 9 years ago
2 4057 9 years ago
Archive · by Muut Archive, 9 years ago
1 2942 9 years ago
Archive · by Muut Archive, 9 years ago
3 1115 9 years ago