feat: localize journal components to Chinese

This commit is contained in:
2026-07-07 23:51:35 +08:00
parent 9a41f541e9
commit 1ef41f04fc
12 changed files with 58 additions and 64 deletions
+15 -19
View File
@@ -44,20 +44,19 @@ function parseInput(raw: string): ParsedInput {
if (raw.startsWith("/roll ")) {
const notation = raw.slice("/roll ".length).trim();
if (!notation)
return { type: "roll", payload: {}, error: "Dice notation required" };
return { type: "roll", payload: {}, error: "需要骰子表达式" };
return { type: "roll", payload: { notation, label: notation } };
}
if (raw.startsWith("/spark ")) {
const key = raw.slice("/spark ".length).trim();
if (!key)
return { type: "spark", payload: {}, error: "Spark table key required" };
if (!key) return { type: "spark", payload: {}, error: "需要种子表键名" };
return { type: "spark", payload: { key } };
}
if (raw.startsWith("/link ")) {
const arg = raw.slice("/link ".length).trim();
if (!arg) return { type: "link", payload: {}, error: "Path required" };
if (!arg) return { type: "link", payload: {}, error: "需要路径" };
const hashIdx = arg.indexOf("#");
const path = hashIdx === -1 ? arg : arg.slice(0, hashIdx);
const section =
@@ -67,7 +66,7 @@ function parseInput(raw: string): ParsedInput {
// /roll, /spark, or /link with no space — need to complete, don't send
if (raw === "/roll" || raw === "/spark" || raw === "/link") {
return { type: "chat", payload: {}, error: "Complete the command" };
return { type: "chat", payload: {}, error: "请补全命令" };
}
return { type: "chat", payload: { text: raw } };
@@ -168,7 +167,7 @@ export const JournalInput: Component = () => {
textareaRef?.focus();
return;
} catch (e) {
setError(e instanceof Error ? e.message : "Failed to roll spark table");
setError(e instanceof Error ? e.message : "种子表掷骰失败");
setSending(false);
return;
}
@@ -216,7 +215,7 @@ export const JournalInput: Component = () => {
);
return matches.length > 0
? matches
: [{ label: "Unknown command", kind: "no-results", insertText: "" }];
: [{ label: "未知命令", kind: "no-results", insertText: "" }];
}
// After /roll — show dice suggestions
@@ -230,7 +229,7 @@ export const JournalInput: Component = () => {
)
.slice(0, 8);
if (matches.length === 0) {
return [{ label: "No dice found", kind: "no-results", insertText: "" }];
return [{ label: "未找到骰子", kind: "no-results", insertText: "" }];
}
return matches.map((d) => ({
label: d.notation,
@@ -252,7 +251,7 @@ export const JournalInput: Component = () => {
if (matches.length === 0) {
return [
{
label: "No spark tables found",
label: "未找到种子表",
kind: "no-results",
insertText: "",
},
@@ -276,9 +275,7 @@ export const JournalInput: Component = () => {
)
.slice(0, 8);
if (matches.length === 0) {
return [
{ label: "No links found", kind: "no-results", insertText: "" },
];
return [{ label: "未找到链接", kind: "no-results", insertText: "" }];
}
return matches.map((l) => {
const insert = l.section
@@ -459,7 +456,7 @@ export const JournalInput: Component = () => {
ref={completionsRef}
class="absolute bottom-full left-0 right-0 bg-white border border-gray-200 rounded-t shadow-lg mb-0.5 z-50 px-3 py-2 text-xs text-gray-400 italic"
>
Loading completions
</div>
</Match>
<Match when={comp.state.status === "error"}>
@@ -467,7 +464,7 @@ export const JournalInput: Component = () => {
ref={completionsRef}
class="absolute bottom-full left-0 right-0 bg-white border border-red-200 rounded-t shadow-lg mb-0.5 z-50 px-3 py-2 text-xs text-red-500"
>
{(comp.state as any).message || "Failed to load completions"}
{(comp.state as any).message || "无法加载补全数据"}
</div>
</Match>
<Match
@@ -486,8 +483,7 @@ export const JournalInput: Component = () => {
when={!isObserver()}
fallback={
<div class="px-3 py-4 text-xs text-gray-400 italic text-center">
You are observing. Open this panel on another device to join as GM
or player.
</div>
}
>
@@ -498,8 +494,8 @@ export const JournalInput: Component = () => {
onKeyDown={handleKeyDown}
placeholder={
isGm()
? "Type a message, or /roll, /spark, or /link..."
: "Type a message..."
? "输入消息,或使用 /roll/spark/link 命令..."
: "输入消息..."
}
rows={2}
class="w-full resize-none border-0 px-3 pt-2.5 pb-1 text-sm
@@ -520,7 +516,7 @@ export const JournalInput: Component = () => {
hover:bg-blue-700 disabled:opacity-40 disabled:cursor-not-allowed
transition-colors"
>
Send
</button>
</div>
</div>