highcharts / highcharts-editor

https://www.highcharts.com/products/highcharts-editor
Other
250 stars 96 forks source link

I18n #101

Closed laurencedorman closed 7 years ago

laurencedorman commented 7 years ago

In relation to #88, I wanted to make a first proposition of what I had in mind when it comes to translating the editor interface.

Following the recommendation of @cvasseng, I placed the entirety of the strings in dictionaries/meta.js in a gettext-like usage of the library i18next.

Now, we can pass an locale argument to the update script eg. node tools/update.meta.js --lang=fr, and a json file of translations corresponding to the locale chosen is loaded to replace the strings in meta.js.

I also added a tool node tools/generate-translations.js to generate the json of strings to translate in order to start a new translation.

I am opening this pull request in order to open a consultation on how to best implement this functionality - it is obviously not ready to be merged as-is. Would this fit in with your vision for where you wanted to take the project in terms of internationalisation ?

cvasseng commented 7 years ago

Sorry for the late response!

Thanks for taking the time to do this.

It falls mostly inline with what I had in mind, except that I wanted to gather all the translations in the highed.localization.js system, and link to it dynamically in the customizer generation so that translations could be "packs" which call e.g. highed.installLanguage(..) to augment localization with additional translations.

The idea then would be that it opens up for switching languages without reloading the page, and for offering translation packs in the form of "one JavaScript file per. language". This would make it easier to include them (no need to run gulp or anything - just include the script for the desired localization).

cvasseng commented 7 years ago

Hello again,

I've now extended the localization system to also include the options from meta.js (d141618081740f12f13d95332516a4c7139d9169). Docs can be found here.

The essence is that translations are added to localization/, and then baked to language packs by running node tools/gen.localization.js. The resulting packs can be included dynamically, and are activated by calling highed.setLang(code).

laurencedorman commented 7 years ago

I see, well thanks for that then. It seems that this PR has served its purpose.