RunestoneInteractive / RunestoneComponents

Packaging of the Runestone tools for publishing educational materials using github pages
http://runestoneinteractive.org
Other
101 stars 225 forks source link

Internationalization of components #1115

Closed larisala closed 3 years ago

larisala commented 3 years ago

Hello, I've been working on translating the components to portuguese. I've created the i18n files with the key value pairs but I cannot make them work. It used to work when the setup functions of each component had the call add_i18n_javascript(app, {"sr-Cyrl"}, "activecode-i18n"), as specified in the I18N.md file, but it doesn't seem to work anymore.

Can someone explain me how to implement internationalization in the latest version?

Thanks

bnmnetp commented 3 years ago

HI @larisala

Thanks for working on this. Since runestone 5.0 we have been using webpack to combine all of the many .js files required for a runestone book into a single runestone.js file. this makes load times MUCH more efficient as it eliminates over 100 requests for javascript or cs from the server for each page.

So, for these internationalization files they need to be imported. For example see line 12 of activecode.js

I'm definitely not an expert in how the jquery internationalization package works but I believe this should do it.

For you to test this you will need to run npm run build to build a new version of the bundled runestone.js file and then rebuild the book you are testing. This section (https://github.com/RunestoneInteractive/RunestoneComponents#developing-and-hacking) covers some other details of getting set up so that the npm commands will work.

Brad

larisala commented 3 years ago

Hi, @bnmnetp, thank you so much for your response, that worked for me! Just out of curiosity, why does the i18n.en file is imported twice in activecode.js (lines 12 and 22)? I suppose we only need one?

bnmnetp commented 3 years ago

Yes, I noticed that there was an extra import there as well. If you want to remove it and include it in your PR that would be great.

Thanks!