How to redirect multilanguage urls in templates and snipets?

Hello everyone,

I m having an issue dealing with a multilingual installation on Kirby 2.
I followed the docs to set it up and got it working for the content, static variables too (ie echo l::get(“something”)) in 2 different languages in my templates and snipets creating a language folder for it.

But I don’t manage to echo a page the right way so it gets the right language.
It allways falls back on the default one.

I m guessing I m doing something wrong in the way I echo pages and subpages but can’t find what…
Here is what is in my template for exemple :

<a href="<?php echo url('proyectos'); ?>"><?php echo l::get('protodo') ?></a></a>

which in the EN version of my website always redirects me to the spanish one…

Does anyone have a clue ?

Thanks a lot

I might be mistaken, but I think the url() function prints the absolute URL of the page, most likely in the default language.

Instead of using url() have you tried using page()->url() ? I’m not sure if it’ll make a difference, but it’s worth to try.

Like this:

<a href="<?php echo page('proyectos')->url(); ?>"><?php echo l::get('protodo') ?></a>

That worked well !

Thanks a lot Paul