OpenLiberty / openliberty.io

Open Liberty website
https://openliberty.io
Other
54 stars 40 forks source link

Translating HTML generated by JavaScript #2775

Open kinueng opened 2 years ago

kinueng commented 2 years ago

There are English messages embedded in JavaScript. Due to being in JS, the code cannot leverage using Liquid tag {% t ... %} from jekyll-multiple-languages-plugin to translate the message.

Here is an example https://github.com/OpenLiberty/openliberty.io/blob/17821c0fef693a78335cf4fb65d19775138024df/src/main/content/_assets/js/post.js#L32

Possible ideas

Instead of using YAML files for externalizing messages, see if jekyll-multiple-languages-plugin can support using JSON files. JSON will allow for us to load the messages in the DOM and give the JS files access to the key: value pairs representing the messages.

natalie-bernhard commented 2 years ago

The multiple languages plugin for Jekyll does not currently support the use of JSON files. There are available command line tools that can convert between YAML and JSON files (example: https://mikefarah.gitbook.io/yq/usage/convert), which could be a possible solution that could convert the files via scripting. However, I'm not sure how much overhead this would entail and whether the overhead is worth it. The command would also require research/vetting to ensure the safety of its use before implementation.