🎉🎉🎉i18n now extends partially to settings and game pages

This commit is contained in:
wearrrrr 2024-01-28 14:11:17 -06:00
parent d45cd21847
commit 50563aaa0b
13 changed files with 175 additions and 142 deletions

View file

@ -10,9 +10,7 @@ const { buttonNameDefault, dropdownList, id } = Astro.props;
<ul class="dropdown-menu" id={id + "-menu"}> <ul class="dropdown-menu" id={id + "-menu"}>
{ {
dropdownList.map((item: any) => { dropdownList.map((item: any) => {
return ( return <li class="dropdown-item" data-setting={item.value}>{item.name}</li>
<li class="dropdown-item" id={`proxy-${item.toLowerCase()}`} data-setting={item}>{item}</li>
)
}) })
} }
</ul> </ul>

View file

@ -10,7 +10,7 @@ const t = useTranslations(lang);
<div class="footerflex"> <div class="footerflex">
<div class="footerbrand"> <div class="footerbrand">
<p class="footerlist-heading"><a href="/">{t("footer.brand")}</a></p> <p class="footerlist-heading"><a href="/">{t("footer.brand")}</a></p>
<p>{t("footer.madeWithLove")}</p> <p><a target="_blank" rel="noopener noreferrer" href="https://wearr.dev">{t("footer.madeWithLove")}</a></p>
</div> </div>
<div class="footerlist"> <div class="footerlist">
<p class="footerlist-heading">{t("footer.services")}</p> <p class="footerlist-heading">{t("footer.services")}</p>

View file

@ -14,7 +14,7 @@ interface Props {
<style> <style>
input { input {
height: 43px; height: 50px;
width: 100%; width: 100%;
border: 4px solid #E0E0E0; border: 4px solid #E0E0E0;
border-radius: 10px; border-radius: 10px;

View file

@ -1,15 +1,25 @@
--- ---
import Dropdown from "../Dropdown.astro" import Dropdown from "../Dropdown.astro"
import Input from "../Input.astro"
const themeList = [
{"name": "Alu", "value": "alu"},
{"name": "Macchiato", "value": "macchiato"},
{"name": "Mocha", "value": "mocha"}
]
const languageList = [
{"name": "English", "value": "en"},
{"name": "日本語", "value": "jp"}
]
--- ---
<div class="settings-container"> <div class="settings-container">
<div class="setting__theme"> <div class="setting__theme">
<label class="setting-label">Theme</label> <label class="setting-label">Theme</label>
<Dropdown buttonNameDefault="Alu" dropdownList={["Alu", "Macchiato", "Mocha"]}, id="dropdown__selected-theme" /> <Dropdown buttonNameDefault="Alu" dropdownList={themeList}, id="dropdown__selected-theme" />
</div> </div>
<div class="setting__language"> <div class="setting__language">
<label class="setting-label">Language</label> <label class="setting-label">Language</label>
<Dropdown buttonNameDefault="English" dropdownList={["English", "日本語"]}, id="dropdown__selected-language" /> <Dropdown buttonNameDefault="English" dropdownList={languageList}, id="dropdown__selected-language" />
</div> </div>
</div> </div>

View file

@ -1,27 +1,51 @@
--- ---
import Input from "../Input.astro" import Input from "../Input.astro"
import Dropdown from "../Dropdown.astro" import Dropdown from "../Dropdown.astro"
import { getLangFromUrl, useTranslations } from "../../i18n/utils"
const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang);
const proxyList = [
{ "name": t("settings.proxy.auto"), "value": "auto" },
{ "name": "Ultraviolet", "value": "ultraviolet" },
{ "name": "Rammerhead", "value": "rammerhead" },
{ "name": "Dynamic", "value": "dynamic" }
]
const searchEngineList = [
{ "name": "Google", "value": "google" },
{ "name": "Bing", "value": "bing" },
{ "name": "Brave", "value": "brave" },
{ "name": "Searx", "value": "searx" }
]
const openPageWith = [
{ "name": t("settings.proxy.openPageWith.embed"), "value": "embed"},
{ "name": "About:Blank", "value": "about:blank" },
{ "name": t("settings.proxy.openPageWith.newTab"), "value": "newTab"}
]
--- ---
<div class="settings-container"> <div class="settings-container">
<div class="setting__selected-proxy"> <div class="setting__selected-proxy">
<label class="setting-label">Selected Proxy</label> <label class="setting-label">{t("settings.proxy.selectedProxy")}</label>
<Dropdown buttonNameDefault="Auto" dropdownList={["Auto", "Ultraviolet", "Dynamic"]}, id="dropdown__selected-proxy" /> <Dropdown buttonNameDefault="Ultraviolet" dropdownList={proxyList}, id="dropdown__selected-proxy" />
</div> </div>
<div class="setting__search-engine"> <div class="setting__search-engine">
<label class="setting-label">Search Engine</label> <label class="setting-label">{t("settings.proxy.searchEngine")}</label>
<Dropdown buttonNameDefault="Google" dropdownList={["Google", "Bing", "Brave", "Searx"]}, id="dropdown__search-engine" /> <Dropdown buttonNameDefault="Google" dropdownList={searchEngineList}, id="dropdown__search-engine" />
</div> </div>
<div class="setting__open_with"> <div class="setting__open_with">
<label class="setting-label">Open With</label> <label class="setting-label">{t("settings.proxy.openPageWith")}</label>
<Dropdown buttonNameDefault="Embed" dropdownList={["Embed", "About:Blank", "New Tab"]}, id="dropdown__open-with" /> <Dropdown buttonNameDefault={t("settings.proxy.openPageWith.embed")} dropdownList={openPageWith}, id="dropdown__open-with" />
</div> </div>
<div class="setting__bare-url"> <div class="setting__bare-url">
<label class="setting-label">Bare URL</label> <label class="setting-label">{t("settings.proxy.bareURL")}</label>
<Input inputName="bare-url" /> <Input inputName="bare-url" />
</div> </div>
</div> </div>
<div class="setting__searxng-url"> <div class="setting__searxng-url">
<label for="searxng-url-input" class="setting-label">Searxng URL</label> <label for="searxng-url-input" class="setting-label">{t("settings.proxy.searxngURL")}</label>
<Input inputName="searxng-url" defaultTextContent="https://searxng.site/" /> <Input inputName="searxng-url" defaultTextContent="https://searxng.site/" />
</div> </div>

View file

@ -42,53 +42,35 @@ import CustomizationTab from "./SettingsContent/CustomizationTab.astro";
</div> </div>
</div> </div>
<script> <script is:inline>
import { navigate } from 'astro:transitions/client';
// Extend window object to store currently selected tab.
declare global {
interface Window {
currentlySelectedTab: string,
loadedContentStorage: any // Technically this is an object storing strings of html, but im lazy.
}
}
document.addEventListener("astro:before-swap", () => { document.addEventListener("astro:before-swap", () => {
window.currentlySelectedTab = "" window.currentlySelectedTab = ""
document.removeEventListener('setting-tabChange', determineListener as EventListener) document.removeEventListener('setting-tabChange', determineListener)
}) })
window.currentlySelectedTab; window.currentlySelectedTab;
window.loadedContentStorage = {} window.loadedContentStorage = {}
function beginLoad() { Array.from(document.getElementsByClassName('setting-tab')).forEach((tab)=>{
Array.from(document.getElementsByClassName('setting-tab')).forEach((tab)=>{ let contentToLoad = document.getElementById('content-' + tab.id)
let contentToLoad = document.getElementById('content-' + tab.id) if (contentToLoad) {
if (contentToLoad) { window.loadedContentStorage[tab.id] = contentToLoad.innerHTML
window.loadedContentStorage[tab.id] = contentToLoad.innerHTML contentToLoad.remove()
contentToLoad.remove() }
}
tab.addEventListener('click', (event) => { tab.addEventListener('click', (event) => {
loadContent((event.target as HTMLElement).id) loadContent(event.target.id)
})
}) })
} })
beginLoad();
function loadContent(tabID) {
function loadContent(tabID: string) {
if (window.currentlySelectedTab == tabID) return if (window.currentlySelectedTab == tabID) return
else window.currentlySelectedTab = tabID else window.currentlySelectedTab = tabID
let currentContent = document.getElementById('current-content') let currentContent = document.getElementById('current-content')
if (currentContent) { if (currentContent) {
currentContent.style.opacity = '0' currentContent.style.opacity = '0'
setTimeout(() => { setTimeout(() => {
if (currentContent) { currentContent.innerHTML = window.loadedContentStorage[tabID]
currentContent.innerHTML = window.loadedContentStorage[tabID] currentContent.style.opacity = '1'
currentContent.style.opacity = '1'
} else {
throw new Error("Current content not found!")
}
document.dispatchEvent(new CustomEvent('setting-tabChange', {detail: tabID })) document.dispatchEvent(new CustomEvent('setting-tabChange', {detail: tabID }))
document.dispatchEvent(new CustomEvent('setting-tabLoad', {detail: tabID })) document.dispatchEvent(new CustomEvent('setting-tabLoad', {detail: tabID }))
}, 250); }, 250);
@ -103,11 +85,11 @@ import CustomizationTab from "./SettingsContent/CustomizationTab.astro";
if (dropdown) { if (dropdown) {
if (dropdown.style.maxHeight == '0px' || dropdown.style.maxHeight == '') { if (dropdown.style.maxHeight == '0px' || dropdown.style.maxHeight == '') {
dropdown.style.maxHeight = dropdown.scrollHeight + 'px'; dropdown.style.maxHeight = dropdown.scrollHeight + 'px';
document.getElementById(toggle.id)!.style.borderRadius = '10px 10px 0 0'; toggle.style.borderRadius = '10px 10px 0 0';
} else { } else {
dropdown.style.maxHeight = '0px'; dropdown.style.maxHeight = '0px';
setTimeout(() => { setTimeout(() => {
document.getElementById(toggle.id)!.style.borderRadius = '10px'; toggle.style.borderRadius = '10px';
}, 300); }, 300);
} }
} }
@ -115,7 +97,7 @@ import CustomizationTab from "./SettingsContent/CustomizationTab.astro";
}) })
} }
function determineListener(event: CustomEvent) { function determineListener(event) {
if (event.detail == "setting-tab-proxy") { if (event.detail == "setting-tab-proxy") {
addDropdownListener() addDropdownListener()
} else if (event.detail == "setting-tab-customization") { } else if (event.detail == "setting-tab-customization") {
@ -123,110 +105,98 @@ import CustomizationTab from "./SettingsContent/CustomizationTab.astro";
} }
} }
function closeDropdown(dropdownID: string) { function closeDropdown(dropdownID) {
let dropdown = document.getElementById(dropdownID) let dropdown = document.getElementById(dropdownID)
if (dropdown) { if (dropdown) {
dropdown.style.maxHeight = '0px'; dropdown.style.maxHeight = '0px';
setTimeout(() => { setTimeout(() => {
let dropdown_toggle = document.getElementById(dropdownID.replace('-menu', '')); let dropdown_toggle = document.getElementById(dropdownID.replace('-menu', ''));
if (dropdown_toggle) { dropdown_toggle.style.borderRadius = '10px';
dropdown_toggle.style.borderRadius = '10px';
} else {
throw new Error("Dropdown toggle not found!")
}
}, 300); }, 300);
} }
} }
function applySavedLocalStorage(localStorageItem: string, dropdownID: string) { function applySavedLocalStorage(localStorageItem, dropdownID) {
if (localStorage.getItem(localStorageItem)) { if (localStorage.getItem(localStorageItem)) {
let dropdown_toggle = document.getElementById(dropdownID); let dropdown_toggle = document.getElementById(dropdownID);
if (dropdown_toggle) { if (dropdown_toggle) {
dropdown_toggle.innerText = (localStorage.getItem(localStorageItem) || "").charAt(0).toUpperCase() + (localStorage.getItem(localStorageItem) || "").slice(1) dropdown_toggle.innerText = JSON.parse(localStorage.getItem(localStorageItem)).name.charAt(0).toUpperCase() + JSON.parse(localStorage.getItem(localStorageItem)).name.slice(1)
} }
} }
} }
function applyDropdownEventListeners(item: HTMLElement, dropdownID: string, localStorageItem: string, optionalCallback: Function | undefined = undefined) { function applyDropdownEventListeners(item, dropdownID, localStorageItem, optionalCallback) {
Array.from(item.children).forEach((item) => { Array.from(item.children).forEach((item) => {
item.addEventListener('click', () => { item.addEventListener('click', () => {
// TODO: Allow an optional field for a custom localStorage value, instead of the input value. // Get position in item.children array
localStorage.setItem(localStorageItem, ((item as HTMLElement).dataset.setting) || "") localStorage.setItem(localStorageItem, JSON.stringify({
applySavedLocalStorage(localStorageItem, dropdownID) "name": item.innerText,
if (item.parentElement) { "value": item.dataset.setting
closeDropdown(item.parentElement.id); }))
} applySavedLocalStorage(localStorageItem, dropdownID)
closeDropdown(item.parentElement.id);
if (typeof optionalCallback == "function") { if (typeof optionalCallback == "function") {
optionalCallback(); optionalCallback();
} }
})
}) })
})
// Array.from(item.children).forEach((item) => {
// item.addEventListener('click', () => {
// localStorage.setItem(localStorageItem, item.dataset.setting)
// applySavedLocalStorage(localStorageItem, dropdownID)
// closeDropdown(item.parentElement.id);
// if (typeof optionalCallback == "function") {
// optionalCallback();
// }
// })
// })
} }
function applyInputListeners(item: HTMLInputElement, localStorageItem: string) { function applyInputListeners(item, localStorageItem) {
item.addEventListener('input', () => { item.addEventListener('input', () => {
// TODO: Allow an optional field for a custom localStorage value, instead of the input value.
localStorage.setItem(localStorageItem, item.value) localStorage.setItem(localStorageItem, item.value)
}) })
} }
document.addEventListener('setting-tabChange', determineListener as EventListener) document.addEventListener('setting-tabChange', determineListener)
loadContent('setting-tab-proxy') loadContent('setting-tab-proxy')
function setupCustomizationSettings() { function setupCustomizationSettings() {
applySavedLocalStorage('alu__selectedTheme', 'dropdown__selected-theme'); applySavedLocalStorage('alu__selectedTheme', 'dropdown__selected-theme');
applySavedLocalStorage('alu__selectedLanguage', 'dropdown__selected-language'); applySavedLocalStorage('alu__selectedLanguage', 'dropdown__selected-language');
// TODO: Null checking lol. let themeDropdown = document.getElementById('dropdown__selected-theme-menu')
let dropdownTheme = document.getElementById('dropdown__selected-theme-menu') as HTMLElement let languageDropdown = document.getElementById('dropdown__selected-language-menu')
let dropdownLanguage = document.getElementById('dropdown__selected-language-menu') as HTMLElement applyDropdownEventListeners(themeDropdown, 'dropdown__selected-theme', 'alu__selectedTheme', changeTheme);
applyDropdownEventListeners(dropdownTheme, 'dropdown__selected-theme', 'alu__selectedTheme', changeTheme); applyDropdownEventListeners(languageDropdown, 'dropdown__selected-language', 'alu__selectedLanguage', navigateToNewLangaugePage);
applyDropdownEventListeners(dropdownLanguage, 'dropdown__selected-language', 'alu__selectedLanguage', navigateToNewLangaugePage);
}
function navigateToNewLangaugePage() {
console.log("Here")
console.log(localStorage.getItem("alu__selectedLanguage"))
switch (localStorage.getItem("alu__selectedLanguage")) {
case "English":
window.location.href = "/en/settings/"
break;
case "日本語":
window.location.href = "/jp/settings/"
break;
}
beginLoad();
} }
function changeTheme() { function changeTheme() {
// || "" is safe to use here, because it will default to the default theme if the localStorage item is not found. let theme = JSON.parse(localStorage.getItem('alu__selectedTheme')).value
let theme = localStorage.getItem('alu__selectedTheme') || ""
if (theme) { if (theme) {
document.documentElement.setAttribute('data-theme', theme.toLowerCase()) document.documentElement.setAttribute('data-theme', theme.toLowerCase())
} let footer = document.getElementById('footer');
let footer = document.getElementById('footer'); if (footer) {
if (footer) {
footer.dataset.theme = theme.toLowerCase(); footer.dataset.theme = theme.toLowerCase();
}
} }
} }
function setupSettings(event: CustomEvent) { function setupSettings(event) {
if (event.detail == "setting-tab-proxy") { if (event.detail == "setting-tab-proxy") {
applySavedLocalStorage('alu__selectedProxy', 'dropdown__selected-proxy'); applySavedLocalStorage('alu__selectedProxy', 'dropdown__selected-proxy');
applySavedLocalStorage('alu__search_engine', 'dropdown__search-engine'); applySavedLocalStorage('alu__search_engine', 'dropdown__search-engine');
applySavedLocalStorage("alu__selectedOpenWith", 'dropdown__open-with'); applySavedLocalStorage("alu__selectedOpenWith", 'dropdown__open-with');
let selectedProxyDropdown = document.getElementById('dropdown__selected-proxy-menu') as HTMLElement let selectedProxyDropdown = document.getElementById('dropdown__selected-proxy-menu')
let searchEngineDropdown = document.getElementById('dropdown__search-engine-menu') as HTMLElement let searchEngineDropdown = document.getElementById('dropdown__search-engine-menu')
let openWithDropdown = document.getElementById('dropdown__open-with-menu') as HTMLElement let openWithDropdown = document.getElementById('dropdown__open-with-menu')
let bareUrlInput = document.getElementById('bare-url-input') as HTMLInputElement let bareUrlInput = document.getElementById('bare-url-input')
let searxngUrlInput = document.getElementById('searxng-url-input') as HTMLInputElement let searxngUrlInput = document.getElementById('searxng-url-input')
let savedSearxngUrl = localStorage.getItem("alu__searxngUrl") let savedSearxngUrl = localStorage.getItem("alu__searxngUrl")
if (savedSearxngUrl != undefined) { if (savedSearxngUrl != undefined) {
if (savedSearxngUrl == "") localStorage.setItem("alu__searxngUrl", "https://searxng.site/") if (savedSearxngUrl == "") localStorage.setItem("alu__searxngUrl", "https://searxng.site/")
// Typescript.. we literally make sure that it won't be undefined RIGHT ABOVE THIS COMMENT. searxngUrlInput.value = JSON.parse(localStorage.getItem("alu__searxngUrl")).value
if (searxngUrlInput) searxngUrlInput.value = localStorage.getItem("alu__searxngUrl") || "https://searxng.site/"
} }
// Proxy settings // Proxy settings
applyInputListeners(bareUrlInput, 'alu__bareUrl') applyInputListeners(bareUrlInput, 'alu__bareUrl')
@ -234,9 +204,8 @@ import CustomizationTab from "./SettingsContent/CustomizationTab.astro";
applyDropdownEventListeners(searchEngineDropdown, 'dropdown__search-engine', 'alu__search_engine', checkSearxng); applyDropdownEventListeners(searchEngineDropdown, 'dropdown__search-engine', 'alu__search_engine', checkSearxng);
applyDropdownEventListeners(selectedProxyDropdown, 'dropdown__selected-proxy', 'alu__selectedProxy'); applyDropdownEventListeners(selectedProxyDropdown, 'dropdown__selected-proxy', 'alu__selectedProxy');
applyDropdownEventListeners(openWithDropdown, 'dropdown__open-with', 'alu__selectedOpenWith'); applyDropdownEventListeners(openWithDropdown, 'dropdown__open-with', 'alu__selectedOpenWith');
// Currently does nothing functionally, but it's here for future use. if (localStorage.getItem('bareUrl')) {
if (localStorage.getItem('alu__bareUrl')) { bareUrlInput.value = localStorage.getItem('bareUrl')
bareUrlInput.value = localStorage.getItem('bareUrl') || ""
} else { } else {
bareUrlInput.value = '/bare/' bareUrlInput.value = '/bare/'
} }
@ -249,15 +218,26 @@ import CustomizationTab from "./SettingsContent/CustomizationTab.astro";
function checkSearxng() { function checkSearxng() {
// This function checks if the "searxng" option was clicked, display an additional option if so. // This function checks if the "searxng" option was clicked, display an additional option if so.
if (localStorage.getItem("alu__search_engine")) { if (localStorage.getItem("alu__search_engine")) {
if ((localStorage.getItem("alu__search_engine") || "").toLowerCase() == "searx") { if (JSON.parse(localStorage.getItem("alu__search_engine")).value.toLowerCase() == "searx") {
(document.getElementsByClassName('setting__searxng-url')[0] as HTMLElement).style.opacity = '1' document.getElementsByClassName('setting__searxng-url')[0].style.opacity = '1'
} else { } else {
(document.getElementsByClassName('setting__searxng-url')[0] as HTMLElement).style.opacity = '0' document.getElementsByClassName('setting__searxng-url')[0].style.opacity = '0'
} }
} }
} }
document.addEventListener('setting-tabLoad', setupSettings as EventListener); document.addEventListener('setting-tabLoad', setupSettings)
function navigateToNewLangaugePage() {
switch (JSON.parse(localStorage.getItem("alu__selectedLanguage")).value) {
case "en":
window.location.href = "/en/settings/"
break;
case "jp":
window.location.href = "/jp/settings/"
break;
}
}
</script> </script>
<style is:global> <style is:global>
.content-hidden { .content-hidden {

View file

@ -3,10 +3,10 @@
let currentTheme = localStorage.getItem("alu__selectedTheme") let currentTheme = localStorage.getItem("alu__selectedTheme")
if (currentTheme) { if (currentTheme) {
document.documentElement.setAttribute("data-theme", currentTheme.toLowerCase()); document.documentElement.setAttribute("data-theme", JSON.parse(currentTheme).value.toLowerCase());
let footer = document.getElementById('footer'); let footer = document.getElementById('footer');
if (footer) { if (footer) {
footer.dataset.theme = currentTheme.toLowerCase(); footer.dataset.theme = JSON.parse(currentTheme).value.toLowerCase();
} }
} }
} }

View file

@ -54,7 +54,7 @@
}; };
function getSearchEngine() { function getSearchEngine() {
switch (localStorage.getItem("alu__search_engine").toLowerCase()) { switch (JSON.parse(localStorage.getItem("alu__search_engine")).value.toLowerCase()) {
case "google": { case "google": {
return "https://google.com/search?q="; return "https://google.com/search?q=";
} }

View file

@ -10,5 +10,18 @@
"footer.madeWithLove": "Made with ❤️ by wearr", "footer.madeWithLove": "Made with ❤️ by wearr",
"footer.services": "Services", "footer.services": "Services",
"footer.socials": "Socials", "footer.socials": "Socials",
"footer.aluProject": "Alu Project" "footer.aluProject": "Alu Project",
"games.title": "Games",
"settings.title": "Settings",
"settings.proxy": "Proxy",
"settings.proxy.auto": "Auto",
"settings.proxy.selectedProxy": "Selected Proxy",
"settings.proxy.searchEngine": "Search Engine",
"settings.proxy.openPageWith": "Open With",
"settings.proxy.openPageWith.embed": "Embed",
"settings.proxy.openPageWith.newTab": "New Tab",
"settings.proxy.searxngURL": "Searx URL",
"settings.proxy.bareURL": "Bare URL"
} }

View file

@ -7,8 +7,20 @@
"menu.search": "検索...", "menu.search": "検索...",
"footer.brand": "アルー", "footer.brand": "アルー",
"footer.madeWithLove": "wearrによる❤️で作られました", "footer.madeWithLove": "wearrによる❤で作られました",
"footer.services": "サービス", "footer.services": "サービス",
"footer.socials": "ソーシャル", "footer.socials": "ソーシャル",
"footer.aluProject": "アループロジェクト" "footer.aluProject": "アループロジェクト",
"games.title": "ゲーム",
"settings.title": "設定",
"settings.proxy": "プロキシ",
"settings.proxy.selectedProxy": "選択されたプロキシ",
"settings.proxy.searchEngine": "検索エンジン",
"settings.proxy.openPageWith": "開く",
"settings.proxy.searxngURL": "SearxのURL",
"settings.proxy.openPageWith.embed": "埋め込み",
"settings.proxy.openPageWith.newTab": "新しいタブ",
"settings.proxy.bareURL": "BareのURL"
} }

View file

@ -100,23 +100,10 @@ body {
body > * { body > * {
opacity: 1; opacity: 1;
} }
/* Create animation to fade in elements */
/* body > * {
animation: fadeIn ease 0.15s;
animation-fill-mode: forwards;
animation-delay: 0.15s;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
} */
.title-text { .title-text {
color: var(--text-color); color: var(--text-color);
text-align: center; text-align: center;
font-weight: 400;
} }
::-webkit-scrollbar { ::-webkit-scrollbar {
display: none; display: none;

View file

@ -2,6 +2,10 @@
import Layout from "../../layouts/Layout.astro"; import Layout from "../../layouts/Layout.astro";
import GameItem from "../../components/GameItem.astro"; import GameItem from "../../components/GameItem.astro";
import { getLangFromUrl, useTranslations } from "../../i18n/utils"
const lang = getLangFromUrl(Astro.url);
const t = useTranslations(lang);
export function getStaticPaths () { export function getStaticPaths () {
return [ return [
{params: {lang: 'en'}}, {params: {lang: 'en'}},
@ -11,7 +15,7 @@ export function getStaticPaths () {
--- ---
<Layout title="Games | Alu"> <Layout title="Games | Alu">
<h1 class="title-text">Games</h1> <h1 class="title-text">{t("games.title")}</h1>
<div class="grid"> <div class="grid">
<GameItem name="1v1.lol" image="/games/1v1.lol/logo.png"></GameItem> <GameItem name="1v1.lol" image="/games/1v1.lol/logo.png"></GameItem>
<GameItem name="2048" image="/games/2048/logo.png"></GameItem> <GameItem name="2048" image="/games/2048/logo.png"></GameItem>
@ -28,7 +32,7 @@ export function getStaticPaths () {
<GameItem name="Death Run 3D" image="/games/death-run-3d/logo.png" slugName="death-run-3d"></GameItem> <GameItem name="Death Run 3D" image="/games/death-run-3d/logo.png" slugName="death-run-3d"></GameItem>
<GameItem name="Doge Miner" image="/games/doge-miner/logo.png" slugName="doge-miner"></GameItem> <GameItem name="Doge Miner" image="/games/doge-miner/logo.png" slugName="doge-miner"></GameItem>
<GameItem name="Doodle Jump" image="/games/doodle-jump/logo.png" slugName="doodle-jump"></GameItem> <GameItem name="Doodle Jump" image="/games/doodle-jump/logo.png" slugName="doodle-jump"></GameItem>
<GameItem name="doom" image="/games/doom/logo.png" slugName="doom"></GameItem> <GameItem name="Doom" image="/games/doom/logo.png" slugName="doom"></GameItem>
<GameItem name="Draw The Hill" image="/games/draw-the-hill/logo.png" slugName="draw-the-hill"></GameItem> <GameItem name="Draw The Hill" image="/games/draw-the-hill/logo.png" slugName="draw-the-hill"></GameItem>
<GameItem name="Evil Glitch" image="/games/evil-glitch/logo.png" slugName="evil-glitch"></GameItem> <GameItem name="Evil Glitch" image="/games/evil-glitch/logo.png" slugName="evil-glitch"></GameItem>
<GameItem name="Fall Boys" image="/games/fall-boys/logo.png" slugName="fall-boys"></GameItem> <GameItem name="Fall Boys" image="/games/fall-boys/logo.png" slugName="fall-boys"></GameItem>

View file

@ -9,17 +9,22 @@ import { ViewTransitions } from "astro:transitions";
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<ViewTransitions /> <ViewTransitions />
<script> <script>
switch (localStorage.getItem("alu__selectedLanguage")) { if (localStorage.getItem("alu__selectedLanguage") === null) window.location.href = "/en/";
case "English": let currentLang = localStorage.getItem("alu__selectedLanguage");
if (currentLang) {
switch (JSON.parse(currentLang).value) {
case "en":
window.location.href = "/en/"; window.location.href = "/en/";
break; break;
case "日本語": case "jp":
window.location.href = "/jp/"; window.location.href = "/jp/";
break; break;
default: default:
window.location.href = "/en/"; window.location.href = "/en/";
break; break;
} }
}
</script> </script>
</head> </head>
<body></body> <body></body>