Closed danielnaber closed 6 years ago
@danielnaber
For now, the work of filling sublangs is done by this function:
We can further produce an object with langs options:
but not only with the selected language but also with the current locale. For example:
Or best solution would be to store this data on the server (for example, the same messages.php). Then when clicking on Language, make AJAX request to api (need to create it, for example /api/sublangs?lang=en&locale=de). Then form the array of languages strings in response and render it on client.
Sorry, the place I pointed was not the most relevant one. https://github.com/languagetool-org/languagetool-website-2018/blob/master/public/js/main.js#L250-L406 is actually more relevant. It populates JS data structures later to be used in editor2.js. Any idea how to simplify this so the data comes from messages.php? I'm not sure Ajax API will work, as this introduces timing issues, so pre-filling on the server seems more robust?
@danielnaber please check changes on 20-passing-messages-to-client
After that all messages are available in the window object and they can be assigned as values for the TinyMCE when it's initialized:
Do you have a suggestion how to translate in JS with the same system as in Laravel? I need to translate this: https://github.com/languagetool-org/languagetool-website-2018/blob/master/public/js/main.js#L77-L90