GispoCoding / master-training-data

Repo for Gispo training materials.
1 stars 0 forks source link

Next and Previous-buttons changed to Finnish #39

Closed jeeemil closed 3 weeks ago

jeeemil commented 1 month ago

Every course page has a "Next" and/or "Previous" button in the end of the page. For language consistency it would be nice to have it in Finnish for the Finnish courses (most of the courses).

ChatGPT suggests

Create or Edit Your custom.js File:

document.addEventListener('DOMContentLoaded', function() {
    var nextButton = document.querySelector('.navbar .navbar-next a');
    var previousButton = document.querySelector('.navbar .navbar-previous a');

    if (nextButton) {
        nextButton.textContent = 'Seuraava';  // Change text to "Seuraava"
    }

    if (previousButton) {
        previousButton.textContent = 'Edellinen';  // Change text to "Edellinen"
    }
});

Possible problems: Finnish buttons appear in English courses.

JuhoErvasti commented 3 weeks ago

@jeeemil This is because we use bookdown to render the html_book and the texts for the buttons are automatically created. We can't really control that at render-time or at least I couldn't find any information on how to do it. There are some possibilities for internationalization but none for the buttons it seems.

JavaScript is probably the best option, I mean you could do some kind of hacky system (Python/bash script) that replaces the button names in the HTML documents...

... but we're already dynamically modifying the texts of the hidden-box buttons with JavaScript so why not do the same here... Choosing the correct language should not be an issue as long as we stick to the course code/folder naming convention where English courses have _eng at the end (and maybe in the future Swedish courses _sv)