From e39690d470ea30343c88b745527d44378cfc093e Mon Sep 17 00:00:00 2001 From: GreenAsJade Date: Wed, 11 Sep 2024 19:59:22 +0930 Subject: [PATCH 1/3] Put back the undebug that got reverted by the big absolute imports merge --- src/views/HelpFlows/GameLogHelp.tsx | 2 +- src/views/User/VoteActivityGraph.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/views/HelpFlows/GameLogHelp.tsx b/src/views/HelpFlows/GameLogHelp.tsx index 50f2590f6e..9491153564 100644 --- a/src/views/HelpFlows/GameLogHelp.tsx +++ b/src/views/HelpFlows/GameLogHelp.tsx @@ -30,7 +30,7 @@ export function GameLogHelp(): JSX.Element { diff --git a/src/views/User/VoteActivityGraph.tsx b/src/views/User/VoteActivityGraph.tsx index 9b375e588c..f8c8a47af3 100644 --- a/src/views/User/VoteActivityGraph.tsx +++ b/src/views/User/VoteActivityGraph.tsx @@ -19,7 +19,7 @@ import React, { useEffect, useState } from "react"; import { get } from "@/lib/requests"; import * as data from "@/lib/data"; -import { ResponsiveLine, Serie } from "@nivo/line"; +import { ResponsiveLine, Serie } from "@nivo/line"; // cspell: ignore Serie import { dropCurrentPeriod } from "@/lib/misc"; interface VoteCountPerDay { From 8a6cb06ecac46a864ca9d54c467c8dc84fb8d2e7 Mon Sep 17 00:00:00 2001 From: GreenAsJade Date: Wed, 11 Sep 2024 20:54:18 +0930 Subject: [PATCH 2/3] Gamelog fixups --- src/views/Game/GameLog.tsx | 4 +++- src/views/HelpFlows/GameLogHelp.tsx | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/views/Game/GameLog.tsx b/src/views/Game/GameLog.tsx index 59a19b1645..50a137811f 100644 --- a/src/views/Game/GameLog.tsx +++ b/src/views/Game/GameLog.tsx @@ -44,7 +44,9 @@ export function GameLog({ const [shouldDisplayFullLog, setShouldDisplayFullLog] = React.useState(false); const { registerTargetItem } = React.useContext(DynamicHelp.Api); - const { ref: autoscoreRef } = registerTargetItem("autoscore-game-log-entry"); + // Defend against the case where we aren't wrapped in a help provider: in a Modal + // TBD: made Modals be able to use the help provider + const autoscoreRef = registerTargetItem?.("autoscore-game-log-entry")?.ref || null; const game_id = goban_config.game_id as number; diff --git a/src/views/HelpFlows/GameLogHelp.tsx b/src/views/HelpFlows/GameLogHelp.tsx index 9491153564..f5806fb44a 100644 --- a/src/views/HelpFlows/GameLogHelp.tsx +++ b/src/views/HelpFlows/GameLogHelp.tsx @@ -19,7 +19,7 @@ import React from "react"; import { HelpFlow, HelpItem } from "react-dynamic-help"; -import { _, pgettext } from "@/lib/translate"; +import { llm_pgettext } from "@/lib/translate"; /** * A help flow intended for moderators and CMs wondering about mysterious auto score entries @@ -31,7 +31,7 @@ export function GameLogHelp(): JSX.Element { id="game-log-help" showInitially={true} debug={false} - description={pgettext("Name of a dynamic help flow", "Game Log Help")} + description={llm_pgettext("Name of a dynamic help flow", "Game Log Help")} >
From 9808393a238465b0e720c57f986fef7d21cdaf8d Mon Sep 17 00:00:00 2001 From: GreenAsJade Date: Wed, 11 Sep 2024 21:25:09 +0930 Subject: [PATCH 3/3] Put back llm_pgettext --- src/lib/translate.ts | 14 ++++++++++++++ src/views/HelpFlows/GameLogHelp.tsx | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/lib/translate.ts b/src/lib/translate.ts index 5961385bad..7710f28318 100644 --- a/src/lib/translate.ts +++ b/src/lib/translate.ts @@ -213,6 +213,20 @@ export function pgettext(context: string, msgid: string) { return debug_wrap(msgid); } +/** + * Like pgettext(), but these strings will be automatically translated instead of passed along to our volunteers. + * + * The context is fed into the LLM system as general instructions and context. + * The msgid is the message that needs to be translated. + */ +export function llm_pgettext(context: string, msgid: string) { + const key = context + "" + msgid; + if (key in catalog) { + return catalog[key][0]; + } + return debug_wrap(msgid); +} + /** * Like pgettext() but for plural forms. */ diff --git a/src/views/HelpFlows/GameLogHelp.tsx b/src/views/HelpFlows/GameLogHelp.tsx index f5806fb44a..e6a960e699 100644 --- a/src/views/HelpFlows/GameLogHelp.tsx +++ b/src/views/HelpFlows/GameLogHelp.tsx @@ -35,7 +35,8 @@ export function GameLogHelp(): JSX.Element { >
- {_( + {llm_pgettext( + "", "These come from the user's browser during autoscoring. Two of these from each user, at the beginning of the scoring phase, and if the users presses 'auto-score'", )}