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

Community guidelines

Please keep discussions civil and on-topic. Repeated violations may lead to a temporary ban.

Support

Strange behaviour of language switcher not picking up language specific slug

Solved by julien View solution

Started by julien 8 years ago · 2 replies · 615 views
8 years ago

Hi everyone,

I'm developing a site which has English (as the default language) and French.
I've followed the doc to install and setup multi language feature.
I've created my pages in English, then did the translation. All the files seems fine and the site is running well.
But I realized a small issue with language switcher.
Example:
I have a page in English called "aquisition" which is also its slug: domain.com/aquisition
Which is fine since I do not want the default language in the URL.
When I check the link of that page in the "fr" link of the language switcher, I see domain.com/fr/aquisition instead of domain.com/fr/acquisition (the spelling is slightly different in french).
But then all menu item when in French are correct. In the menu I see domain.com/fr/acquisition which is fine.

Am I missing a setting some where. I've read a lot and search a lot but aside from a github
issue saying that it's not possible; I haven't been able to figure this one out.

Thank you in advance.

8 years ago

Have you set the 'slug' in the french page? Like:

YAML
---
title: Acquisition
slug: acquisition
---

And in /user/config/system.yaml:

YAML
pages:
  redirect_default_route: true
last edited 08/22/18 by pamtbaau
8 years ago Solution

Thanks pamtbaau,

I had set the slug properly but I guess I've trying different settings and could not make it work.
Though, I realized that the actual link of the "fr" version is pointing at the english slug of the page but with /fr/ prepended. And when you click, it redirect to the correct slug.
This is where grav's magic is happening !

So all good on my side.

We can close that one as "Solved".

Thanks again for your very quick help.

Suggested topics

Topic Participants Replies Views Activity
Support · by Thomas, 1 week ago
2 64 18 hours ago
Support · by Anna, 3 days ago
2 68 20 hours ago
Support · by Justin Young, 21 hours ago
1 35 21 hours ago
Support · by Duc , 1 week ago
2 71 6 days ago
Support · by Colin Hume, 1 week ago
2 63 6 days ago