Skip to content

Commit

Permalink
Merge pull request #2828 from GreenAsJade/absolute_import_fixups
Browse files Browse the repository at this point in the history
Absolute import fixups
  • Loading branch information
anoek authored Sep 11, 2024
2 parents cec0f15 + 9808393 commit 40912f6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
14 changes: 14 additions & 0 deletions src/lib/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
4 changes: 3 additions & 1 deletion src/views/Game/GameLog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 5 additions & 4 deletions src/views/HelpFlows/GameLogHelp.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,12 +30,13 @@ export function GameLogHelp(): JSX.Element {
<HelpFlow
id="game-log-help"
showInitially={true}
debug={true}
description={pgettext("Name of a dynamic help flow", "Game Log Help")}
debug={false}
description={llm_pgettext("Name of a dynamic help flow", "Game Log Help")}
>
<HelpItem target="autoscore-game-log-entry" position={"bottom-center"}>
<div>
{_(
{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'",
)}
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/views/User/VoteActivityGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 40912f6

Please sign in to comment.