{{- /*
Send readers to the docs in their own language.
Only English pages that have a translation get this script. When a reader
arrives on one from outside the site (a search result, a link, a bookmark),
we pick a language in this order:
1. The language they last chose in the header language menu.
2. Their browser's preferred languages, in order. If English comes first
in that list we stop and keep English.
If that language has a translation of this page we replace the URL, keeping
the query string and anchor, so the back button never bounces between the
two versions.
We never redirect when the reader got here by clicking within the docs. A
translated page links to English for the sections we don't translate
(releases, supported_tools), and a reader who picks English in the language
menu must be able to stay there. Picking any language in that menu is saved
and wins over the browser setting from then on.
Crawlers are left alone: every version is listed through hreflang links and
the per-language sitemaps, so search engines index each language on its own
URL.
*/ -}}
{{- if and (eq .Lang "en") .IsTranslated }}
{{- $translations := dict }}
{{- range .Translations }}
{{- $translations = merge $translations (dict .Lang .RelPermalink) }}
{{- end }}
{{- end }}