Skip to content

Commit 115218d

Browse files
committed
refactor: add localized names to rule selection UI
1 parent b881fd2 commit 115218d

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/lib/rules-explanation.ts

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ export type RuleExplanation = {
99

1010
export const rulesExplanation = {
1111
lifespan: {
12+
name: {
13+
ja: "寿命システム",
14+
en: "Lifespan system",
15+
},
16+
description: {
17+
ja: "それぞれのいのちに寿命を設定できます",
18+
en: "Set lifespan for each cell",
19+
},
1220
code: lifespan,
13-
ja: "それぞれのいのちに寿命を設定できます",
14-
en: "Set lifespan for each cell",
1521
},
1622
probabilistics: {
23+
name: {
24+
ja: "確率システム",
25+
en: "Probabilistic system",
26+
},
27+
description: {
28+
ja: "生死に確率を導入できます",
29+
en: "Introduce probability to life and death",
30+
},
1731
code: probabilistics,
18-
ja: "生死に確率を導入できます",
19-
en: "Introduce probability to life and death",
2032
},
2133
};

src/routes/+page.svelte

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import { javascript } from "@codemirror/lang-javascript";
1616
import { oneDark } from "@codemirror/theme-one-dark";
1717
import { EditorView } from "@codemirror/view";
18+
import { is } from "valibot";
1819
1920
let editingCode = $state(lifeGameJS);
2021
let appliedCode = $state(lifeGameJS);
@@ -232,18 +233,20 @@
232233
>
233234
<div class="bg-[rgb(220,220,220)] shadow-lg p-4 h-30 w-full overflow-x-auto">
234235
<div class="flex gap-4">
235-
{#each Object.entries(rulesExplanation) as [ruleName, description] (ruleName)}
236+
{#each Object.entries(rulesExplanation) as [ruleName, ruleData] (ruleName)}
236237
<button
237238
class="card bg-base-100 shadow-md hover:shadow-lg transition-shadow cursor-pointer text-left flex-shrink-0 w-64"
238239
onclick={() => {
239-
selectRule(description as RuleExplanation);
240+
selectRule(ruleData.name as RuleExplanation);
240241
ruleDrawerOpen = false;
241242
}}
242243
>
243244
<div class="card-body p-4">
244-
<h3 class="card-title text-lg text-primary">{ruleName}</h3>
245+
<h3 class="card-title text-lg text-primary">
246+
{isJapanese ? ruleData.name.ja : ruleData.name.en}
247+
</h3>
245248
<p class="text-sm text-base-content">
246-
{isJapanese ? description.ja : description.en}
249+
{isJapanese ? ruleData.description.ja : ruleData.description.en}
247250
</p>
248251
</div>
249252
</button>

0 commit comments

Comments
 (0)