Skip to content

Commit

Permalink
extract localization for multiplayer hero games & tags
Browse files Browse the repository at this point in the history
  • Loading branch information
jwunderl committed Sep 27, 2023
1 parent 4d66d4c commit 508f4ae
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
21 changes: 20 additions & 1 deletion cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,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 =
Expand Down Expand Up @@ -1900,6 +1900,25 @@ ${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;
}
}
}
// extract strings from editor
["editor", "fieldeditors", "cmds"]
Expand Down
4 changes: 2 additions & 2 deletions multiplayer/src/components/JoinOrHost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@ export default function Render() {
return (
<HostGameButton
shareId={game.shareId}
title={game.title}
subtitle={game.subtitle}
title={pxt.Util.rlf(`{id:game-title}${game.title}`)}
subtitle={pxt.Util.rlf(`{id:game-subtitle}${game.subtitle}`)}
image={resourceUrl(game.image)}
key={i}
/>
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/extensionsBrowser.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ export const ExtensionsBrowser = (props: ExtensionsProps) => {
{categoryNames.map(c =>
<Button title={pxt.Util.rlf(c)}
key={c}
label={pxt.Util.rlf(c)}
label={pxt.Util.rlf(`{id:extension-tag}${c}`)}
onClick={() => handleCategoryClick(c)}
onKeydown={() => handleCategoryClick}
className={"extension-tag " + (selectedTag == c ? "selected" : "")}
Expand Down

0 comments on commit 508f4ae

Please sign in to comment.