-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up imports, add language support for map
- Loading branch information
1 parent
ee5b80c
commit 2b3f433
Showing
5 changed files
with
111 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
export default { | ||
map: { | ||
unfocused: "Unfocused - click here to focus", | ||
}, | ||
modes: { | ||
sprint_10l: { | ||
title: "Sprint", | ||
subtitle: "10L", | ||
description: "Clear 10 lines!" | ||
}, | ||
sprint_20l: { | ||
title: "Sprint", | ||
subtitle: "20L", | ||
description: "Clear 20 lines!" | ||
}, | ||
sprint_40l: { | ||
title: "Sprint", | ||
subtitle: "40L", | ||
description: "Clear 40 lines!" | ||
}, | ||
sprint_100l: { | ||
title: "Sprint", | ||
subtitle: "100L", | ||
description: "Clear 100 lines!" | ||
}, | ||
sprint_400l: { | ||
title: "Sprint", | ||
subtitle: "400L", | ||
description: "Clear 400 lines!" | ||
}, | ||
sprint_1000l: { | ||
title: "Sprint", | ||
subtitle: "1000L", | ||
description: "Clear 1000 lines!" | ||
}, | ||
sprintPenta: { | ||
title: "Sprint", | ||
subtitle: "Pentomino", | ||
description: "40L with 18 pentominoes" | ||
}, | ||
sprintMPH: { | ||
title: "Sprint", | ||
subtitle: "MPH", | ||
description: "Memoryless\nPreviewless\nHoldless" | ||
}, | ||
sprint123: { | ||
title: "Sprint", | ||
subtitle: "M123", | ||
description: "40L with only monominoes, dominoes, and triminoes" | ||
}, | ||
construct_sg: { | ||
title: "Construct", | ||
subtitle: "SECRET GRADE", | ||
description: "Build a zigzag pattern by following the guide!" | ||
}, | ||
construct_checker: { | ||
title: "Construct", | ||
subtitle: "CHECKERBOARD", | ||
description: "Build a checkerboard pattern!" | ||
}, | ||
construct_invsg: { | ||
title: "Construct", | ||
subtitle: "INV. SG", | ||
description: "Build an inverted zigzag pattern!" | ||
}, | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
let langEntries = {}; | ||
|
||
export function getCurrentLang() { | ||
return localStorage.getItem('lang') || 'en'; | ||
} | ||
export function getLangFilePath(lang) { | ||
lang = lang ?? getCurrentLang(); | ||
return `/data/lang/${lang}.js`; | ||
} | ||
export function getLanguageEntry(key, fallback) { | ||
if(typeof key !== 'string') throw new Error("Key must be a string!"); | ||
fallback ??= key; | ||
|
||
let keys = key.split('.'); | ||
let scope = langEntries; | ||
for(let i = 0; i < keys.length; i++) { | ||
if(typeof scope !== 'object') return fallback; | ||
if(!scope[keys[i]]) return fallback; | ||
scope = scope[keys[i]]; | ||
} | ||
return scope; | ||
}; | ||
export function getLanguageEntries() { | ||
return langEntries; | ||
}; | ||
export async function setLanguage(lang){ | ||
if(lang === localStorage.getItem('lang')) return; | ||
if(typeof lang !== 'string') throw new Error("Language must be a string!"); | ||
localStorage.setItem('lang', lang); | ||
|
||
langEntries = (await import(getLangFilePath(lang))).default; | ||
} | ||
|
||
langEntries = (await import(getLangFilePath())).default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters