8.4.2 How to redirect for multilingual site?

Permalink
I use lots of links and redirections throughout my package, e.g.
<a href="<?php echo \URL::to('/', 'products'); ?>"><?php echo t('Buy'); ?></a>

The site tree is split into languages: en and ru, e.g. /en/products, /ru/products.

What can I do to redirect to the correct locale based on the current language?

linuxoid
 
mnakalay replied on at Permalink Reply
mnakalay
if you look in the switch_language block you'll have everything you need
linuxoid replied on at Permalink Reply
linuxoid
As I see that block, when you click on the flag, it resolves the current page and loads the same in the selected language.

But what I have is a simple link from one page to another. It works fine on one locale, e.g. clicking /en/products will go there. But copying of the page tree does not copy and substitute the links, that is the same link in another locale remains the same.

Is there anything which would change the root '/' to the language root, e.g. '/ru/' but only if multilingual is set up (otherwise it stays as '/') and which would then redirect to the proper locale after changing the language?

BTW, I need that for a single page, not a block (if that matters)
mnakalay replied on at Permalink Reply
mnakalay
You can also look at this tutorial to give you some useful tips:https://documentation.concrete5.org/tutorials/global-areas-for-each-...