Forum

Thread tagged as: Question

Language parameter as part of routing param?

Is it possible to always have 'language' param added to routing so it remains dynamic for all pages.

for .e.g. instead of showing content for https://domain.com/about, same content is served as https://domain.com/es/about, and when language is swtiched, changes to '/de/about'.

I can currently achieve this by adding /es/about to routing for the page.

this would help me keep separate URL's and use the 'language' parameter in the page to show language specific content and still not duplicate sites.

client usually want multi-language sites, but almost always forgets to update content in each site/language admin

sawan ruparel

sawan ruparel 0 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Create a custom routing token to match your language options, and then add a route to the page with that token.

'routing_tokens' => [
    'lang' => '[a-z]{2}',
],
[lang:lang]/about

This is brilliant... love the support and kool hidden features :-)

Drew McLellan

Drew McLellan 2638 points
Perch Support

We hide these things in the documentation ;)

https://docs.grabaperch.com/runway/routing/custom-tokens/

lol ;-)