From 82ec037166f553ba70c0ccb341db2a73d4604109 Mon Sep 17 00:00:00 2001 From: Joey Wunderlich Date: Fri, 29 Sep 2023 10:38:54 -0700 Subject: [PATCH] extract localization for multiplayer hero games & tags (#9698) * extract localization for multiplayer hero games & tags * also translate descriptions for hw --- cli/cli.ts | 28 ++++++++++++++++++++++- multiplayer/src/components/JoinOrHost.tsx | 4 ++-- webapp/src/extensionsBrowser.tsx | 2 +- webapp/src/projects.tsx | 2 +- 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/cli/cli.ts b/cli/cli.ts index 74b36c33b248..2bbb4430a2e3 100644 --- a/cli/cli.ts +++ b/cli/cli.ts @@ -1840,7 +1840,7 @@ function saveThemeJson(cfg: pxt.TargetBundle, localDir?: boolean, packaged?: boo walkDocs(theme.docMenu); if (nodeutil.fileExistsSync("targetconfig.json")) { const targetConfig = nodeutil.readJson("targetconfig.json") as pxt.TargetConfig; - if (targetConfig && targetConfig.galleries) { + if (targetConfig?.galleries) { const docsRoot = nodeutil.targetDir; let gcards: pxt.CodeCard[] = []; let tocmd: string = @@ -1891,6 +1891,32 @@ ${gcards.map(gcard => `[${gcard.name}](${gcard.url})`).join(',\n')} `, { encoding: "utf8" }); } + const multiplayerGames = targetConfig?.multiplayer?.games; + for (const game of (multiplayerGames ?? [])) { + if (game.title) targetStrings[`{id:game-title}${game.title}`] = game.title; + if (game.subtitle) targetStrings[`{id:game-subtitle}${game.subtitle}`] = game.subtitle; + } + + const approvedRepoLib = targetConfig?.packages?.approvedRepoLib; + for (const [extension, repoData] of Object.entries(approvedRepoLib ?? {})) { + for (const tag of (repoData.tags ?? [])) { + targetStrings[`{id:extension-tag}${tag}`] = tag; + } + } + + const builtinExtensionLib = targetConfig?.packages?.builtinExtensionsLib; + for (const [extension, repoData] of Object.entries(builtinExtensionLib ?? {})) { + for (const tag of (repoData.tags ?? [])) { + targetStrings[`{id:extension-tag}${tag}`] = tag; + } + } + + const hardwareOptions = targetConfig?.hardwareOptions; + for (const opt of (hardwareOptions ?? [])) { + // Not translating hardware name, as that is typically a brand name / etc. + if (opt.description) + targetStrings[`{id:hardware-description}${opt.description}`] = opt.description; + } } // extract strings from editor ["editor", "fieldeditors", "cmds"] diff --git a/multiplayer/src/components/JoinOrHost.tsx b/multiplayer/src/components/JoinOrHost.tsx index 7fc7fb9e78d5..72e41afe64d7 100644 --- a/multiplayer/src/components/JoinOrHost.tsx +++ b/multiplayer/src/components/JoinOrHost.tsx @@ -157,8 +157,8 @@ export default function Render() { return ( diff --git a/webapp/src/extensionsBrowser.tsx b/webapp/src/extensionsBrowser.tsx index 0faa9f0c4d0d..1c94663abeba 100644 --- a/webapp/src/extensionsBrowser.tsx +++ b/webapp/src/extensionsBrowser.tsx @@ -524,7 +524,7 @@ export const ExtensionsBrowser = (props: ExtensionsProps) => { {categoryNames.map(c =>