Skip to content

Commit

Permalink
fixing genaiscript
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Dec 12, 2024
1 parent 92f53ff commit b032f94
Show file tree
Hide file tree
Showing 9 changed files with 136 additions and 21 deletions.
21 changes: 21 additions & 0 deletions gamepad/_locales/de/jacdac-gamepad-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"jacdac.GamepadEvent.ButtonsChanged": "Argument: buttons Buttons (uint32_t). Wird immer dann ausgelöst, wenn sich der Zustand der Tasten ändert.\n* ```\nconst [buttons] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadEventPack.ButtonsChanged": "Packformat für 'buttons_changed' Daten.",
"jacdac.GamepadReg.ButtonsAvailable": "Konstante Tasten (uint32_t). Gibt eine Bitmaske der Tasten an, die auf dem Gamepad montiert sind.\nWenn die `Left`/`Up`/`Right`/`Down` Tasten hier als verfügbar markiert sind, ist das Gamepad digital.\nSelbst wenn sie als nicht verfügbar markiert sind, werden sie dennoch basierend auf dem analogen Gamepad simuliert.\n* ```\nconst [buttonsAvailable] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadReg.Direction": "Wenn das Gamepad analog ist, sollten die Richtungstasten basierend auf der Gamepad-Position \"simuliert\" werden\n(`Left` ist `{ x = -1, y = 0 }`, `Up` ist `{ x = 0, y = -1}`).\nWenn das Gamepad digital ist, dann wird jede Richtung entweder als `-1`, `0` oder `1` gelesen (in fester Darstellung).\nDie primäre Taste auf dem Gamepad ist `A`.\n* ```\nconst [buttons, x, y] = jdunpack<[jacdac.GamepadButtons, number, number]>(buf, \"u32 i1.15 i1.15\")\n```",
"jacdac.GamepadReg.Variant": "Konstanter Variant (uint8_t). Der Typ des physischen Gamepads.\n* ```\nconst [variant] = jdunpack<[jacdac.GamepadVariant]>(buf, \"u8\")\n```",
"jacdac.GamepadRegPack.ButtonsAvailable": "Packformat für 'buttons_available' Daten.",
"jacdac.GamepadRegPack.Direction": "Packformat für 'direction' Daten.",
"jacdac.GamepadRegPack.Variant": "Packformat für 'variant' Daten.",
"modules": "Jacdac-Module",
"modules.GamepadClient": "Ein zweiachssiger Richtungs-Joystick",
"modules.GamepadClient.buttons": "Wenn der Joystick analog ist, sollten die Richtungstasten basierend auf der Joystick-Position \"simuliert\" werden\n(`Left` ist `{ x = -1, y = 0 }`, `Up` ist `{ x = 0, y = -1}`).\nWenn der Joystick digital ist, dann wird jede Richtung entweder als `-1`, `0` oder `1` gelesen (in fester Darstellung).\nDie primäre Taste auf dem Joystick ist `A`.",
"modules.GamepadClient.buttonsAvailable": "Gibt eine Bitmaske der Tasten an, die auf dem Joystick montiert sind.\nWenn die `Left`/`Up`/`Right`/`Down` Tasten hier als verfügbar markiert sind, ist der Joystick digital.\nSelbst wenn sie als nicht verfügbar markiert sind, werden sie dennoch basierend auf dem analogen Joystick simuliert.",
"modules.GamepadClient.isButtonDown": "Gibt an, ob die Taste (oder Kombination) gedrückt ist.",
"modules.GamepadClient.isButtonDown|param|button": "@returns true, wenn ausgewählte Tasten gedrückt sind",
"modules.GamepadClient.onButtonsChanged": "Wird immer dann ausgelöst, wenn sich der Zustand der Tasten ändert.",
"modules.GamepadClient.onEvent": "Code registrieren, der ausgeführt wird, wenn ein Ereignis ausgelöst wird",
"modules.GamepadClient.variant": "Der Typ des physischen Joysticks.",
"modules.GamepadClient.x": "Wenn der Joystick analog ist, sollten die Richtungstasten basierend auf der Joystick-Position \"simuliert\" werden\n(`Left` ist `{ x = -1, y = 0 }`, `Up` ist `{ x = 0, y = -1}`).\nWenn der Joystick digital ist, dann wird jede Richtung entweder als `-1`, `0` oder `1` gelesen (in fester Darstellung).\nDie primäre Taste auf dem Joystick ist `A`.",
"modules.GamepadClient.y": "Wenn der Joystick analog ist, sollten die Richtungstasten basierend auf der Joystick-Position \"simuliert\" werden\n(`Left` ist `{ x = -1, y = 0 }`, `Up` ist `{ x = 0, y = -1}`).\nWenn der Joystick digital ist, dann wird jede Richtung entweder als `-1`, `0` oder `1` gelesen (in fester Darstellung).\nDie primäre Taste auf dem Joystick ist `A`."
}
32 changes: 32 additions & 0 deletions gamepad/_locales/de/jacdac-gamepad-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"jacdac.GamepadButtons.A|block": "a",
"jacdac.GamepadButtons.B|block": "b",
"jacdac.GamepadButtons.Down|block": "unten",
"jacdac.GamepadButtons.Exit|block": "beenden",
"jacdac.GamepadButtons.Left|block": "links",
"jacdac.GamepadButtons.Menu|block": "menü",
"jacdac.GamepadButtons.Reset|block": "zurücksetzen",
"jacdac.GamepadButtons.Right|block": "rechts",
"jacdac.GamepadButtons.Select|block": "auswählen",
"jacdac.GamepadButtons.Up|block": "oben",
"jacdac.GamepadButtons.X|block": "x",
"jacdac.GamepadButtons.Y|block": "y",
"jacdac.GamepadEvent.ButtonsChanged": "Argument: Buttons (uint32_t). Wird immer ausgegeben, wenn sich der Zustand der Tasten ändert.\n* ```\nconst [buttons] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadEvent.ButtonsChanged|block": "Tasten geändert",
"jacdac.GamepadReg.ButtonsAvailable": "Konstante Tasten (uint32_t). Zeigt eine Bitmaske der Tasten an, die auf dem Gamepad angebracht sind.\nWenn die `Links`/`Oben`/`Rechts`/`Unten`-Tasten hier als verfügbar markiert sind, ist das Gamepad digital.\nSelbst wenn sie als nicht verfügbar markiert sind, werden sie dennoch basierend auf dem analogen Gamepad simuliert.\n* ```\nconst [buttonsAvailable] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadReg.Direction": "Wenn das Gamepad analog ist, sollten die Richtungstasten basierend auf der Gamepad-Position \"simuliert\" werden\n(`Links` ist `{ x = -1, y = 0 }`, `Oben` ist `{ x = 0, y = -1 }`).\nWenn das Gamepad digital ist, wird jede Richtung als entweder `-1`, `0` oder `1` gelesen (in fester Darstellung).\nDie Primärtaste des Gamepads ist `A`.\n* ```\nconst [buttons, x, y] = jdunpack<[jacdac.GamepadButtons, number, number]>(buf, \"u32 i1.15 i1.15\")\n```",
"jacdac.GamepadReg.Variant": "Konstante Variante (uint8_t). Der Typ des physischen Gamepads.\n* ```\nconst [variant] = jdunpack<[jacdac.GamepadVariant]>(buf, \"u8\")\n```",
"jacdac.GamepadVariant.ArcadeBall|block": "Arcade-Kugel",
"jacdac.GamepadVariant.ArcadeStick|block": "Arcade-Stick",
"jacdac.GamepadVariant.Gamepad|block": "Gamepad",
"jacdac.GamepadVariant.Thumb|block": "Daumen",
"modules.GamepadClient.isButtonDown|block": "%joystick ist Taste $button unten",
"modules.GamepadClient.onEvent|block": "wenn %gamepad %event",
"modules.GamepadClient.x|block": "%joystick x",
"modules.GamepadClient.y|block": "%joystick y",
"modules.gamepad1|block": "Gamepad1",
"modules|block": "Module",
"{id:category}Jacdac": "Jacdac",
"{id:category}Modules": "Module",
"{id:group}Button": "Knopf"
}
21 changes: 21 additions & 0 deletions gamepad/_locales/jacdac-gamepad-jsdoc-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"jacdac.GamepadEvent.ButtonsChanged": "Argument: buttons Buttons (uint32_t). Emitted whenever the state of buttons changes.\n* ```\nconst [buttons] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadEventPack.ButtonsChanged": "Pack format for 'buttons_changed' data.",
"jacdac.GamepadReg.ButtonsAvailable": "Constant Buttons (uint32_t). Indicates a bitmask of the buttons that are mounted on the gamepad.\nIf the `Left`/`Up`/`Right`/`Down` buttons are marked as available here, the gamepad is digital.\nEven when marked as not available, they will still be simulated based on the analog gamepad.\n* ```\nconst [buttonsAvailable] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadReg.Direction": "If the gamepad is analog, the directional buttons should be \"simulated\", based on gamepad position\n(`Left` is `{ x = -1, y = 0 }`, `Up` is `{ x = 0, y = -1}`).\nIf the gamepad is digital, then each direction will read as either `-1`, `0`, or `1` (in fixed representation).\nThe primary button on the gamepad is `A`.\n* ```\nconst [buttons, x, y] = jdunpack<[jacdac.GamepadButtons, number, number]>(buf, \"u32 i1.15 i1.15\")\n```",
"jacdac.GamepadReg.Variant": "Constant Variant (uint8_t). The type of physical gamepad.\n* ```\nconst [variant] = jdunpack<[jacdac.GamepadVariant]>(buf, \"u8\")\n```",
"jacdac.GamepadRegPack.ButtonsAvailable": "Pack format for 'buttons_available' data.",
"jacdac.GamepadRegPack.Direction": "Pack format for 'direction' data.",
"jacdac.GamepadRegPack.Variant": "Pack format for 'variant' data.",
"modules": "Jacdac modules",
"modules.GamepadClient": "A two axis directional joystick",
"modules.GamepadClient.buttons": "If the joystick is analog, the directional buttons should be \"simulated\", based on joystick position\n(`Left` is `{ x = -1, y = 0 }`, `Up` is `{ x = 0, y = -1}`).\nIf the joystick is digital, then each direction will read as either `-1`, `0`, or `1` (in fixed representation).\nThe primary button on the joystick is `A`.",
"modules.GamepadClient.buttonsAvailable": "Indicates a bitmask of the buttons that are mounted on the joystick.\nIf the `Left`/`Up`/`Right`/`Down` buttons are marked as available here, the joystick is digital.\nEven when marked as not available, they will still be simulated based on the analog joystick.",
"modules.GamepadClient.isButtonDown": "Indicates if the button (or combination of) is down.",
"modules.GamepadClient.isButtonDown|param|button": "@returns true if selected buttons are down",
"modules.GamepadClient.onButtonsChanged": "Emitted whenever the state of buttons changes.",
"modules.GamepadClient.onEvent": "Register code to run when an event is raised",
"modules.GamepadClient.variant": "The type of physical joystick.",
"modules.GamepadClient.x": "If the joystick is analog, the directional buttons should be \"simulated\", based on joystick position\n(`Left` is `{ x = -1, y = 0 }`, `Up` is `{ x = 0, y = -1}`).\nIf the joystick is digital, then each direction will read as either `-1`, `0`, or `1` (in fixed representation).\nThe primary button on the joystick is `A`.",
"modules.GamepadClient.y": "If the joystick is analog, the directional buttons should be \"simulated\", based on joystick position\n(`Left` is `{ x = -1, y = 0 }`, `Up` is `{ x = 0, y = -1}`).\nIf the joystick is digital, then each direction will read as either `-1`, `0`, or `1` (in fixed representation).\nThe primary button on the joystick is `A`."
}
32 changes: 32 additions & 0 deletions gamepad/_locales/jacdac-gamepad-strings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"jacdac.GamepadButtons.A|block": "a",
"jacdac.GamepadButtons.B|block": "b",
"jacdac.GamepadButtons.Down|block": "down",
"jacdac.GamepadButtons.Exit|block": "exit",
"jacdac.GamepadButtons.Left|block": "left",
"jacdac.GamepadButtons.Menu|block": "menu",
"jacdac.GamepadButtons.Reset|block": "reset",
"jacdac.GamepadButtons.Right|block": "right",
"jacdac.GamepadButtons.Select|block": "select",
"jacdac.GamepadButtons.Up|block": "up",
"jacdac.GamepadButtons.X|block": "x",
"jacdac.GamepadButtons.Y|block": "y",
"jacdac.GamepadEvent.ButtonsChanged": "Argument: buttons Buttons (uint32_t). Emitted whenever the state of buttons changes.\n* ```\nconst [buttons] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadEvent.ButtonsChanged|block": "buttons changed",
"jacdac.GamepadReg.ButtonsAvailable": "Constant Buttons (uint32_t). Indicates a bitmask of the buttons that are mounted on the gamepad.\nIf the `Left`/`Up`/`Right`/`Down` buttons are marked as available here, the gamepad is digital.\nEven when marked as not available, they will still be simulated based on the analog gamepad.\n* ```\nconst [buttonsAvailable] = jdunpack<[jacdac.GamepadButtons]>(buf, \"u32\")\n```",
"jacdac.GamepadReg.Direction": "If the gamepad is analog, the directional buttons should be \"simulated\", based on gamepad position\n(`Left` is `{ x = -1, y = 0 }`, `Up` is `{ x = 0, y = -1}`).\nIf the gamepad is digital, then each direction will read as either `-1`, `0`, or `1` (in fixed representation).\nThe primary button on the gamepad is `A`.\n* ```\nconst [buttons, x, y] = jdunpack<[jacdac.GamepadButtons, number, number]>(buf, \"u32 i1.15 i1.15\")\n```",
"jacdac.GamepadReg.Variant": "Constant Variant (uint8_t). The type of physical gamepad.\n* ```\nconst [variant] = jdunpack<[jacdac.GamepadVariant]>(buf, \"u8\")\n```",
"jacdac.GamepadVariant.ArcadeBall|block": "arcade ball",
"jacdac.GamepadVariant.ArcadeStick|block": "arcade stick",
"jacdac.GamepadVariant.Gamepad|block": "gamepad",
"jacdac.GamepadVariant.Thumb|block": "thumb",
"modules.GamepadClient.isButtonDown|block": "%joystick is button $button down",
"modules.GamepadClient.onEvent|block": "on %gamepad %event",
"modules.GamepadClient.x|block": "%joystick x",
"modules.GamepadClient.y|block": "%joystick y",
"modules.gamepad1|block": "gamepad1",
"modules|block": "modules",
"{id:category}Jacdac": "Jacdac",
"{id:category}Modules": "Modules",
"{id:group}Button": "Button"
}
19 changes: 13 additions & 6 deletions gen-locs.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import "zx/globals"
import { run } from "genaiscript/api"

const target = "microbit"
const targets = ["microbit", "arcade"]
const langs = ["de"]

const libs = (await fs.readdir(".", { withFileTypes: true }))
Expand All @@ -17,14 +18,20 @@ for (const lib of libs) {
if (lib !== ".") cd(lib)
try {
const pkg = fs.readJSONSync("pxt.json")
if (!pkg.supportedTargets?.includes(target)) continue
if (!targets.some(target => pkg.supportedTargets?.includes(target)))
continue
await $`pxt install`
await $`pxt gendocs --locs`
await $`git checkout -- 'pxt.json'`.nothrow()
// update translations as needed
const tool = `${lib === "." ? "" : "../"}genaisrc/loc-strings.genai.js`
for (const lang of langs)
await $`genaiscript run ${tool} "_locales/*-strings.json" --apply-edits --vars target=${target} lang=${lang}`.nothrow()
const tool = `${lib === "." ? "" : "../"}genaisrc/loc-strings.genai.mjs`
for (const lang of langs) {
console.log(`generating locs ${lib} for ${lang}`)
$`genaiscript run ${tool} _locales/*-strings.json --vars lang=${lang}`.nothrow()
// await run(tool, files, {
// applyEdits: true,
// varsMap: { lang: lang },
// })
}
// add generated files to pxt.json
let modded = false
const locs = await glob(`_locales/*/*.json`)
Expand Down
6 changes: 0 additions & 6 deletions gen-locs.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,3 @@
#!/bin/sh

set -e

npm install -g pxt
npm install -g genaiscript
npm install -g zx
pxt target microbit
node gen-locs.mjs
2 changes: 1 addition & 1 deletion genaisrc/loc-strings.genai.mts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const langName = {
if (!langName) cancel(`unknown language ${langCode}`)

const files = env.files.filter(({ filename }) =>
/\/_locales\/[a-z0-9\-_]+-strings\.json$/i.test(filename)
/^_locales\/[a-z0-9\-_]+-strings\.json$/i.test(filename)
)
for (const file of files) {
await translateFile(file)
Expand Down
8 changes: 8 additions & 0 deletions setup-locs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

set -e

npm install -g pxt
npm install -D [email protected]
npm install -D zx
pxt target microbit
16 changes: 8 additions & 8 deletions wind-speed/pxt.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
"name": "jacdac-wind-speed",
"version": "1.9.28",
"description": "A sensor that measures wind speed.",
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"files": [
"constants.ts",
"client.g.ts",
"_locales/de/jacdac-wind-speed-strings.json"
],
"testFiles": [],
"testDependencies": {
"nucleo-f411re": "*"
},
"supportedTargets": [
"arcade",
"microbit",
"maker",
"calliopemini"
],
"dependencies": {
"core": "*",
"jacdac": "github:microsoft/pxt-jacdac"
},
"testDependencies": {
"nucleo-f411re": "*"
}
]
}

0 comments on commit b032f94

Please sign in to comment.