Multilingual 404 page

Hi!
I’m making a multilingual website for my client. Since my website has three languages, I need three 404 error pages.

I could only find one solution - in this thread. I tried to apply it on my site, but it didn’t work.

Maybe some of you can see what I did wrong and why this solution didn’t work?
Thanks!


Here is my site Read-Only: LINK

I found a solution. Thanks to gpt chat for this. Here is an example of working code:

<script>
document.addEventListener('DOMContentLoaded', function () {
    // Find all elements with classes "error-english", "error-russian", and "error-ukrainian"
    const englishDiv = document.querySelector('.error-english');
    const russianDiv = document.querySelector('.error-russian');
    const ukrainianDiv = document.querySelector('.error-ukrainian');

  // Get the current page URL
    const currentURL = window.location.href;

    // Define language based on URL
    let language = 'uk'; // Ukrainian by default

    if (currentURL.includes('/ru')) {
        language = 'ru';
    } else if (currentURL.includes('/en')) {
        language = 'en';
    }

    // Hide all divs
    englishDiv.style.display = 'none';
    russianDiv.style.display = 'none';
    ukrainianDiv.style.display = 'none';

    // Display div according to the selected language
    switch (language) {
        case 'en':
            englishDiv.style.display = 'block';
            break;
        case 'ru':
            russianDiv.style.display = 'block';
            break;
        case 'uk':
            ukrainianDiv.style.display = 'block';
            break;
        default:
            // If language is not defined, display Ukrainian by default
            ukrainianDiv.style.display = 'block';
            break;
    }
});
 </script>