From 386d4b018fd7755a4a4d0ad065545e038a0f3d06 Mon Sep 17 00:00:00 2001 From: Joey Wunderlich Date: Thu, 5 Oct 2023 10:19:02 -0700 Subject: [PATCH] [stable8.5-Arcade] Port hw dialogue fixes (#9707) * Pull hw options from target config (#9696) * pull from targetconfig instead of /hardware * update comment * extract localization for multiplayer hero games & tags (#9698) * extract localization for multiplayer hero games & tags * also translate descriptions for hw --- cli/cli.ts | 28 +++++++++++++++- localtypings/pxtarget.d.ts | 2 ++ multiplayer/src/components/JoinOrHost.tsx | 4 +-- webapp/src/extensionsBrowser.tsx | 2 +- webapp/src/projects.tsx | 40 ++++++++--------------- 5 files changed, 46 insertions(+), 30 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/localtypings/pxtarget.d.ts b/localtypings/pxtarget.d.ts index 4f3594a00978..bd154b1e62dd 100644 --- a/localtypings/pxtarget.d.ts +++ b/localtypings/pxtarget.d.ts @@ -28,6 +28,8 @@ declare namespace pxt { // localized galleries localizedGalleries?: pxt.Map>; windowsStoreLink?: string; + // localized options on download dialog; name, description, url, imageUrl, variant used. + hardwareOptions?: CodeCard[]; // release manifest for the electron app electronManifest?: pxt.electron.ElectronManifest; profileNotification?: ProfileNotification; 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 =>