(function () { "use strict"; var root = document.documentElement; var onRuPage = location.pathname.indexOf("/ru/") === 0 || location.pathname === "/ru"; var stored = null; var theme = null; try { stored = localStorage.getItem("cursorlang.lang"); theme = localStorage.getItem("cursorlang.theme"); } catch (error) { // Storage refused: what the URL says stands } // A stored choice always wins, on either page. if (stored === "ru" && !onRuPage) { location.replace("/ru/" + location.search + location.hash); return; } if (stored === "en" && onRuPage) { location.replace("/" + location.search + location.hash); return; } // No stored choice yet: send a browser set to Russian to the Russian page, // once. Never redirect away from a page a link already pointed at — a // shared /ru/ link, or a crawler fetching either URL directly, stands. if (!stored && !onRuPage && (navigator.language || "").toLowerCase().indexOf("ru") === 0) { location.replace("/ru/" + location.search + location.hash); return; } var lang = onRuPage ? "ru" : "en"; root.setAttribute("data-lang", lang); root.setAttribute("lang", lang); if (theme === "dark" || theme === "light") { root.setAttribute("data-theme", theme); } }());