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/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 50f2590f6e..e6a960e699 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 @@ -30,12 +30,13 @@ 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'", )}
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 {