Multilingual 404 page

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?

Here is my site Read-Only: LINK

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

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 = 'none'; = 'none'; = 'none';

    // Display div according to the selected language
    switch (language) {
        case 'en':
   = 'block';
        case 'ru':
   = 'block';
        case 'uk':
   = 'block';
            // If language is not defined, display Ukrainian by default
   = 'block';