mo4islona / node-blockly

Blockly for Node.js and Browser via CommonJS module
133 stars 81 forks source link

No i18n support #12

Closed NAllred91 closed 7 years ago

NAllred91 commented 7 years ago

It looks like this library only supports english. Is there any way you know of to add additional translation files?

mo4islona commented 7 years ago

I'll try to implement i18n

NAllred91 commented 7 years ago

@mo4islona It looks like adding all the languages will add about 500kb+ to the size of the package. I wonder if it could be implemented in a way where you can import just the languages you want and the unused languages can be removed using tree shaking by whoever is using this library.

For now, I'm able to grab the files out of the blockly repo and use them on my application side.

mo4islona commented 7 years ago

Please try the latest version

import Blockly from 'node-blockly/browser';
import De from 'node-blockly/lib/i18n/de';
Blockly.setLocale(De)
mo4islona commented 7 years ago

Dynamic imports also works but Blockly doesn't re-render workspace. You must re-render it manually after locale loaded

Check https://github.com/mo4islona/node-blockly/blob/master/test/browser/index.js#L25

mo4islona commented 7 years ago

Also check the async locales demo http://mo4islona.github.io/blockly/

NAllred91 commented 7 years ago

@mo4islona Thanks, this was really easy to swap out my temporary hack with what you implemented.