Skip to content

Commit 62ab8f9

Browse files
Translation preparation (#26)
- Tweaks to jsdoc strings for translation to help pxt gendocs tool pick up all strings - Add MakeCode strings files - Add "unknown" to translatable strings for sim extension
1 parent 6989765 commit 62ab8f9

File tree

7 files changed

+40
-6
lines changed

7 files changed

+40
-6
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"mlrunner.customOnEvent": "Register a TypeScript function to run when an event is raised.\n* This custom version of the MakeCode onEvent function is needed due to:\nhttps://github.com/microsoft/pxt-microbit/issues/5709\n*",
3+
"mlrunner.customOnEvent|param|flags": "The specified event flags are ignored and configured via pxt.json.",
4+
"mlrunner.customOnEvent|param|handler": "The function to call when the event is detected.",
5+
"mlrunner.customOnEvent|param|src": "The ID of the component to listen to.",
6+
"mlrunner.customOnEvent|param|value": "The event value to listen to from that component."
7+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"ml.event.Unknown|block": "unknown",
3+
"ml.getCertainty|block": "certainty (\\%) ML $event",
4+
"ml.isDetected|block": "is ML $event detected",
5+
"ml.onStart|block": "on ML $event start",
6+
"ml.onStopDetailed|block": "on ML $event stop $duration (ms)",
7+
"ml.onStop|block": "on ML $event stop",
8+
"mlrunner|block": "mlrunner",
9+
"{id:category}Ml": "Ml",
10+
"{id:category}MlEvent": "MlEvent",
11+
"{id:category}Mlrunner": "Mlrunner",
12+
"{id:group}micro:bit (V2)": "micro:bit (V2)"
13+
}

pxtextension.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,11 +163,11 @@ namespace mlrunner {
163163
* This custom version of the MakeCode onEvent function is needed due to:
164164
* https://github.com/microsoft/pxt-microbit/issues/5709
165165
*
166+
*
166167
* @param src The ID of the component to listen to.
167168
* @param value The event value to listen to from that component.
168169
* @param handler The function to call when the event is detected.
169-
* @param flags The specified event flags are ignored and configured via
170-
* pxt.json.
170+
* @param flags The specified event flags are ignored and configured via pxt.json.
171171
*/
172172
//%
173173
void customOnEvent(int src, int value, Action handler, int flags = 0) {

shims.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ declare namespace mlrunner {
77
* This custom version of the MakeCode onEvent function is needed due to:
88
* https://github.com/microsoft/pxt-microbit/issues/5709
99
*
10+
*
1011
* @param src The ID of the component to listen to.
1112
* @param value The event value to listen to from that component.
1213
* @param handler The function to call when the event is detected.
13-
* @param flags The specified event flags are ignored and configured via
14-
* pxt.json.
14+
* @param flags The specified event flags are ignored and configured via pxt.json.
1515
*/
1616
//% flags.defl=0 shim=mlrunner::customOnEvent
1717
function customOnEvent(src: int32, value: int32, handler: () => void, flags?: int32): void;

simx/lang/ui.en.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,9 @@
22
"select-label": {
33
"defaultMessage": "ML event:",
44
"description": "Label for the simulator event select input"
5+
},
6+
"unknown-event-label": {
7+
"defaultMessage": "unknown",
8+
"description": "Label the default ML event"
59
}
610
}

simx/src/Simulator.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* SPDX-License-Identifier: MIT
55
*/
66
import { ChangeEvent, useCallback, useEffect, useRef, useState } from "react";
7-
import { FormattedMessage } from "react-intl";
7+
import { FormattedMessage, useIntl } from "react-intl";
88
import "./simulator.css";
99

1010
type MessageType = "register" | "data" | "request_data" | "simulate_event";
@@ -20,11 +20,15 @@ interface EventData {
2020
}
2121

2222
const simChannel = "microbit-foundation/pxt-microbit-ml";
23-
const defaultEvent: EventData = { name: "unknown", value: 1 };
2423
const textDecoder = new TextDecoder();
2524
const textEncoder = new TextEncoder();
2625

2726
const Simulator = () => {
27+
const intl = useIntl();
28+
const defaultEvent: EventData = {
29+
name: intl.formatMessage({ id: "unknown-event-label" }),
30+
value: 1,
31+
};
2832
const [events, setEvents] = useState<EventData[]>([defaultEvent]);
2933
const [selectedEvent, setSelectedEvent] = useState<number>(
3034
defaultEvent.value

simx/src/messages/ui.en.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
"type": 0,
55
"value": "ML event:"
66
}
7+
],
8+
"unknown-event-label": [
9+
{
10+
"type": 0,
11+
"value": "unknown"
12+
}
713
]
814
}

0 commit comments

Comments
 (0)