Skip to content

add ability to localize callback parameters #10567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 8, 2025

Conversation

riknoll
Copy link
Member

@riknoll riknoll commented May 7, 2025

fixes microsoft/pxt-microbit#1507

this PR adds the ability to localize callback parameters in blocks with draggable reporters. the json entries for callback parameters look like this:

// qname|handlerParam|paramName
"radio.onReceivedString|handlerParam|receivedString": "receivedString",

i went with this format over the usual {id:whatever} thing we use for most rlf strings because i wanted to match what we do for the other block strings, which i guess predate the nicer curly brace syntax.

in order to actually display these strings, i store this localization rlf key as a mutation in the block when generating XML for the toolbox. that means this will not retroactively apply to old projects, which will not have the mutation present. also, this will still compile to the actual parameter name when switching to javascript rather than the localized one

@riknoll riknoll requested a review from a team May 7, 2025 21:40
@riknoll
Copy link
Member Author

riknoll commented May 7, 2025

i should mention that this isn't a perfect solution, in particular this won't work automatically for blocks in tutorials. however, i think it should work if the person authoring the tutorial simply writes a valid localized identifier in the javascript that we decompile into blocks.

i haven't thought up a good decompiler scenario for this yet... it's tough to associate arguments with their functions since they are separate blocks. right now they'll lose the localization if they start in blocks, switch to javascript, make a change, and switch back to blocks

@riknoll riknoll merged commit a299d4a into master May 8, 2025
19 checks passed
@riknoll riknoll deleted the dev/riknoll/localize_handler_params branch May 8, 2025 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

receivedNumber, receivedString not translatable
3 participants