Skip to content

Commit

Permalink
Put log event strings through a decode function, use that to explain …
Browse files Browse the repository at this point in the history
…a nonintuitive one.
  • Loading branch information
GreenAsJade committed Oct 28, 2024
1 parent 632e239 commit 1e92786
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/views/Game/GameLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import * as React from "react";
import moment from "moment";

import { _, pgettext } from "@/lib/translate";
import { _, llm_pgettext, pgettext } from "@/lib/translate";
import * as DynamicHelp from "react-dynamic-help";

import { LogEntry } from "@/views/Game";
Expand Down Expand Up @@ -135,7 +135,7 @@ export function GameLog({
<td className="timestamp">
{moment(entry.timestamp).format("L LTS")}
</td>
<td className="event">{entry.event.replace(/_/g, " ")}</td>
<td className="event">{decodeLogEvent(entry.event)}</td>
<td className="data">
<LogData
config={goban_config}
Expand All @@ -161,6 +161,17 @@ export function GameLog({
);
}

// Provide a human-readable version of the event name
const decodeLogEvent = (event: string): string => {
if (event === "force_stone_removal_acceptance_abandoned") {
return llm_pgettext(
"Description of an event from the server",
"Forcing stone removal: someone abandoned scoring",
);
}
return event.replace(/_/g, " ");
};

// Fields that are only used to enhance the display of other fields,
// or aren't used at all.
const HIDDEN_LOG_FIELDS = [
Expand Down Expand Up @@ -190,7 +201,7 @@ export function LogData({
return;
}

// Possibly obvious once you think about it: the "stones" field in `data` referring to
// Possibly obvious once you think about it: the "stones" field in `data` is referring to
// "stones that are dead, or have been marked alive"
// It'd be better if this was called "marked stones", but that'd be a big change.

Expand Down

0 comments on commit 1e92786

Please sign in to comment.