Localize using Javascript

116 views
Skip to first unread message

Sethuraman

unread,
Feb 1, 2019, 1:29:47 AM2/1/19
to Blockly
Hi All,


May i know how to localize custom blocks using Javascript , Need to change the field place according to language.

kushal bhattacharya

unread,
Feb 1, 2019, 6:44:15 AM2/1/19
to Blockly
refer to this link 

instead of en.js  , you include whatever language you want to include in your application

Andrew n marshall

unread,
Feb 1, 2019, 2:05:47 PM2/1/19
to blo...@googlegroups.com
Hi Sethuraman,

At the moment, Blockly only supports updating the localization prior to loading the blocks. Load the correct msg/js file into your HTML and that will write the correct localized values to the Blockly.Msg string table.

Some developers have implemented re-localization without a page reload (Scratch, for instance). We do not have support for this out if the box. However, the process is relatively straight forward:
1. Save the workspace to XML and clear it.
2. Reassign Blockly.Msg. One can probably either source the appropriate msg/js file, or get the same info from the msg/json equivalent.
3. Reload all the blocks definitions into Blockly.Blocks. This might not be necessary, but I think this will catch some edge cases with some block definition extensions.
4. Reload toolbox XML.
5. Reload workspace from saved XML.

Because of the save/reload cycle, you may lose minor UI state like workspace panned location.


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages