Skip to content
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

Translation of two (and only two) built-in blocks is not done when switching language. #1964

Closed
aroberge opened this issue Jul 2, 2018 · 3 comments

Comments

@aroberge
Copy link

aroberge commented Jul 2, 2018

Problem statement

I have a custom language switcher which refreshes the strings (messages) on the blocks. I used it without problems for at least 2 if not 3 years. Just a few days ago, I updated to the most recent version of blockly as I wanted to add support for a new language. In doing so, I found out that the strings for two built-in blocks (controls_whileUntil and controls_flow_statements) are not updated when I change the language; all other blocks are translated correctly.

The translations shown correspond to the default used when the page was loaded and are never updated afterwards for these two blocks.

Expected Behavior

Correct behaviour as seen on (old "stable/public" version) http://reeborg.ca/reeborg.html

Loading the page for the first time; the default language is English:

image

Switching to French:

image

Note that the bottom two blocks shown are translated correctly.

Actual Behavior

Newer (testing) version; starting in English (https://aroberge.github.io/reeborg-staging/)

image

Switching to French:

image

Note that the bottom block is not translated; the one above is is only partially translated.

When a user select a language, I save it in localStorage. Upon reloading the page, the correct translation are shown:

image

Steps to Reproduce

See above

Stack Traces

None

Operating System and Browser

I have only tested on Windows 10. I see this problem using the latest versions of Chrome, Firefox and Edge.

Additional Information

To use blockly, I simply copied the compressed version and other relevant files from your repository. https://github.com/aroberge/reeborg/blob/master/reeborg.html#L603

To enable my own custom language switching, I've edited the language files as follows:

goog.provide('Blockly.Msg.en');
//
// goog.require('Blockly.Msg');
// Blockly.Msg["LOOPS_HUE"] is commented out at bottom for Reeborg

function blockly_init_en () {
Blockly.Msg["ADD_COMMENT"] = "Add Comment";
...
Blockly.Msg["VARIABLES_DYNAMIC_HUE"] = "310";
}
blockly_init_en();

(See https://github.com/aroberge/reeborg/tree/master/src/blockly_msg)

When switching to a different language, I simply call the relevant blockly_init_xx().

Edit

When I run the program locally (using https://github.com/aroberge/reeborg/blob/master/serve_reeborg.py), the two blocks get updated correctly when I switch language.

@aroberge
Copy link
Author

aroberge commented Jul 2, 2018

Could this be related to #1895 - more specifically #1895 (comment)? Looking at https://github.com/google/blockly/blob/master/blocks/loops.js, I see that the block I use appear to be defined using the JSON notation and use the JSON defined static list of dropdown options. [1]

If so, is there a way for me to define equivalent blocks without using the JSON notation as a workaround?


[1] Although, I do not understand how the updating would work when running a local version of my site as mentioned in the edit at the bottom of the bug report.

@RoboErikG
Copy link
Contributor

Yep, that's the same bug. Thanks for pointing out a use case to help us prioritize it.

Until we work out a fix the two ways you could get around it on your end are:

  1. Force a reload with the new language as a query parameter by setting window.location to the current page, but with a different language. This is what Blockly Games does.

  2. Revert the change to move these blocks into JSON arrays that are only loaded once: a4cfd5c#diff-d82ae6d79436427c586b9b2622578f4b

@RoboErikG
Copy link
Contributor

Dupe of #1895

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

No branches or pull requests

2 participants