microsoft / pxt-microbit

A Blocks / JavaScript code editor for the micro:bit built on Microsoft MakeCode
https://makecode.microbit.org
Other
710 stars 586 forks source link

Allow simulator extensions to know the current language for translations #5746

Closed microbit-matt-hillsdon closed 2 weeks ago

microbit-matt-hillsdon commented 1 month ago

Is your feature request related to a problem? Please describe.

The Foundation would like to ship a simulator extension alongside our machine learning tool work so that users can trigger ML events in the sim.

We've modelled our prototype on the jacdac simulator extension.

So far as I can tell there's no way to get at the language configured in MakeCode and therefore use suitable translations.

This issue also affects editor extensions with the embedded iframe accessible from the extension's toolbox section. It would be good for there to be a consistent solution for both extension types.

Describe the solution you'd like Language is communicated to the extension on load and when it changes if the extension isn't reloaded at that point.

This could be a URL parameter or some postMessage-based messaging.

CC @jaustin @abchatra

jaustin commented 1 month ago

@pelikhan, @abchatra thought that this might already be done? Do you know the way to translate simulator extensions?

microbit-matt-hillsdon commented 1 month ago

I had a look and can't see how this can be done right now so I've open a PR. But totally possible I missed something so please let me know.