Change LANG verion on current page

Hello. I need help.

I have the pages

https://site.ru/ru/cdn/ - RU verision
https://site.ru/cdn/ - EN version

I want to create universal lang switch. I want that when I click to EN link, watche ENG version page. And if I click to RU link - I watche the RUS version page.

Have a look at the example in the docs.

This decision does not suit me. I need to always show language links. (See the image by reference)

Example

I have code:

{{ range .Translations }}
		{{ if eq .Lang "en" }}
					<a href="{{ .URL }}" class="active_l">{{ T "lang_en" }}</a>
					<a href="{{ .Permalink }}">{{ T "lang_ru" }}</a>
		{{ else }}
					<a href="{{ .Permalink }}">{{ T "lang_en" }}</a>
					<a href="{{ .URL }}" class="active_l">{{ T "lang_ru" }}</a>
		{{ end }}
{{ end}}	

But now Permalink and URL refer to the same address.
I need them to refer to their version

I decided this way

{{ if .IsTranslated }}
	{{ if eq .Lang "en" }}
		<a href="{{ .URL }}" class="active_l">{{ T "lang_en" }}</a>
	{{ end }}
    {{ range .Translations }}
	{{ if eq .Lang "en" }}
		<a href="{{ .URL }}">{{ T "lang_en" }}</a>
	{{ else }}
		<a href="{{ .URL }}">{{ T "lang_ru" }}</a>
	{{ end }}
    {{ end}}
	{{ if eq .Lang "ru" }}
		<a href="{{ .URL }}" class="active_l">{{ T "lang_ru" }}</a>
	{{ end }}
{{ end }}
1 Like

You can also use .AllTranslations which will include your current language.