73 lines
1.7 KiB
HTML
73 lines
1.7 KiB
HTML
<style>
|
|
.lang-toggle {
|
|
position: fixed;
|
|
top: 12px;
|
|
right: 12px;
|
|
z-index: 1000;
|
|
display: flex;
|
|
gap: 2px;
|
|
background: #fff;
|
|
border: 1px solid #d0d7de;
|
|
border-radius: 6px;
|
|
overflow: hidden;
|
|
box-shadow: 0 1px 3px rgba(0,0,0,0.12);
|
|
}
|
|
.lang-toggle a {
|
|
padding: 4px 10px;
|
|
font-size: 13px;
|
|
font-weight: 500;
|
|
text-decoration: none;
|
|
color: #656d76;
|
|
transition: background 0.15s, color 0.15s;
|
|
}
|
|
.lang-toggle a:hover {
|
|
background: #0969da;
|
|
color: #fff;
|
|
}
|
|
.lang-toggle a.active {
|
|
background: #0969da;
|
|
color: #fff;
|
|
pointer-events: none;
|
|
}
|
|
@media (prefers-color-scheme: dark) {
|
|
.lang-toggle {
|
|
background: #161b22;
|
|
border-color: #30363d;
|
|
}
|
|
.lang-toggle a {
|
|
color: #8b949e;
|
|
}
|
|
.lang-toggle a:hover {
|
|
background: #1f6feb;
|
|
color: #fff;
|
|
}
|
|
.lang-toggle a.active {
|
|
background: #1f6feb;
|
|
color: #fff;
|
|
}
|
|
}
|
|
</style>
|
|
<div class="lang-toggle" role="navigation" aria-label="Language switcher">
|
|
<a href="#" class="active" data-lang="en">EN</a>
|
|
<a href="#" data-lang="pt">PT</a>
|
|
</div>
|
|
<script>
|
|
(function() {
|
|
var path = window.location.pathname.replace(/\/unleash/, '') || '/';
|
|
var isPt = path.startsWith('/pt');
|
|
var enPath = path.replace(/^\/pt/, '') || '/';
|
|
var ptPath = '/pt' + (path === '/' || path === '/pt' ? '' : path.replace(/^\/pt/, '')) || '/pt/';
|
|
|
|
var links = document.querySelectorAll('.lang-toggle a');
|
|
links.forEach(function(link) {
|
|
var lang = link.getAttribute('data-lang');
|
|
var href = lang === 'en' ? '/unleash' + enPath : '/unleash' + ptPath;
|
|
href = href.replace(/\/+/g, '/');
|
|
link.href = href;
|
|
if ((lang === 'en' && !isPt) || (lang === 'pt' && isPt)) {
|
|
link.classList.add('active');
|
|
}
|
|
});
|
|
})();
|
|
</script>
|