Skip to content

Conversation

@gonfunko
Copy link
Contributor

This PR fixes #412 by updating the keyboard experimentation repo to reference localizable strings from core Blockly instead of hard coding them.

@gonfunko gonfunko requested a review from a team as a code owner April 21, 2025 17:47
@gonfunko gonfunko requested review from BenHenning and removed request for a team April 21, 2025 17:47
Copy link
Collaborator

@BenHenning BenHenning left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gonfunko! LGTM, though I did have some thoughts on the messages naming (though that would presumably require changes here & in v12, so I defer to your judgment on how you want to proceed).

const oldDisplayText = this.oldContextMenuItem
.displayText as DisplayTextFn;
return oldDisplayText(scope) + ' (Del)';
return oldDisplayText(scope) + ` (${shortcut})`;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this localize for RTL correctly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, but this is kind of a hack in the first place so I think that's acceptable for now.

if (!this.tryShowFullBlockFieldEditor(block)) {
const shortcut = getShortActionShortcut('list_shortcuts');
const message = `Press ${shortcut} for help on keyboard controls`;
const message = Msg['HELP_PROMPT'].replace('%1', shortcut);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here & elsewhere: how descriptive do the names need to be? If they are global context, I'd expect something like: KEYBOARD_SHORTCUTS_HELP_PROMPT to be much clearer and avoid potential duplications in the future. If this level of specificity is preferred, can all of the other ones be updated accordingly?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

...I realize we just release core, so we're kind of committed now. Sorry I missed this until I went looking for things to pick up now that that was out the door :/

@rachel-fenichel
Copy link
Collaborator

I think this needs one more rebase.

@gonfunko gonfunko merged commit 8077c06 into main May 19, 2025
8 checks passed
@gonfunko gonfunko deleted the localization branch May 19, 2025 18:41
Comment on lines +30 to +36
private shortcutNames: string[] = [];
private menuItemNames: string[] = [];

private registerShortcuts() {
const shortcuts: ShortcutRegistry.KeyboardShortcut[] = [
// Begin and end move.
{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@gonfunko:

Moving the list of shortcuts from the class definition into a method makes it impossible to reference them from elsewhere, obliging you to add a separate private member just the shortcuts can later be unregistered. This is inelegant and complicates certain other refactors, such as making this horrid bit of code a bit less opaque by having it actually reference the keybindings used by these shortcuts.

Since you are not an idiot, I presume you must have had a good reason to do this.

One obvious good reason would be to delay evaluation of the Msg[…] lookups until after messages are loaded. But I cannot see any point in time between when the MoveActions constructor is called and when moveActions.init() is called when it is possible to load messages, since both things happen as a result of the construction of the NavigationController instance.

What am I missing here?

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.

5 participants