Advertisement
Igor150195

dddddd

Feb 27th, 2025
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2.     document.addEventListener("DOMContentLoaded", function() {
  3.         const userLang = navigator.language || navigator.userLanguage;
  4.  
  5.         let localePostfix;
  6.  
  7.         if (["nl", "nl-NL"].includes(userLang) && !['/nl'].includes(location.pathname) && !localStorage.getItem("lang-popup-flag")) {
  8.             localePostfix = '/nl';
  9.  
  10.             $('.language-popup-title').html($('.language-popup-title').data('nl'));
  11.             $('.lang-popup-or-text').html($('.lang-popup-or-text').data('nl'));
  12.             $('.lang-popup-dropdown-text').html($('.lang-popup-dropdown-text').data('nl'));
  13.             $('#close-lang-popup').html($('#close-lang-popup').data('nl'));
  14.             $('#confirm-lang-redirect').html($('#confirm-lang-redirect').data('nl'));
  15.  
  16.             let text = $('#language-popup .w-locales-items a[hreflang="nl"]').text();
  17.             let img = $('#language-popup .w-locales-items a[hreflang="nl"]').prev().clone();
  18.  
  19.             $('#language-popup .w-locales-items a[hreflang="nl"]').parents('.popup-locale-item').hide();
  20.  
  21.             //$('#language-popup .popup-lang').text(text);
  22.             $('#language-popup .locale-flag').html(img);
  23.  
  24.             $('#language-popup').css('display', 'flex');
  25.         } else if (["fr", "fr-FR"].includes(userLang) && !['/fr'].includes(location.pathname) && !localStorage.getItem("lang-popup-flag")) {
  26.             localePostfix = '/fr';
  27.  
  28.             $('.language-popup-title').html($('.language-popup-title').data('fr'));
  29.             $('.lang-popup-or-text').html($('.lang-popup-or-text').data('fr'));
  30.             $('.lang-popup-dropdown-text').html($('.lang-popup-dropdown-text').data('fr'));
  31.             $('#close-lang-popup').html($('#close-lang-popup').data('fr'));
  32.             $('#confirm-lang-redirect').html($('#confirm-lang-redirect').data('fr'));
  33.  
  34.             let text = $('#language-popup .w-locales-items a[hreflang="fr-FR"]').text();
  35.             let img = $('#language-popup .w-locales-items a[hreflang="fr-FR"]').prev().clone();
  36.  
  37.             $('#language-popup .w-locales-items a[hreflang="fr-FR"]').parents('.popup-locale-item').hide();
  38.  
  39.             //$('#language-popup .popup-lang').text(text);
  40.             $('#language-popup .locale-flag').html(img);
  41.  
  42.             $('#language-popup').css('display', 'flex');
  43.         } else if (["es", "es-ES"].includes(userLang) && !['/es'].includes(location.pathname) && !localStorage.getItem("lang-popup-flag")) {
  44.             localePostfix = '/es';
  45.  
  46.             $('.language-popup-title').html($('.language-popup-title').data('es'));
  47.             $('.lang-popup-or-text').html($('.lang-popup-or-text').data('es'));
  48.             $('.lang-popup-dropdown-text').html($('.lang-popup-dropdown-text').data('es'));
  49.             $('#close-lang-popup').html($('#close-lang-popup').data('es'));
  50.             $('#confirm-lang-redirect').html($('#confirm-lang-redirect').data('es'));
  51.  
  52.             let text = $('#language-popup .w-locales-items a[hreflang="es-ES"]').text();
  53.             let img = $('#language-popup .w-locales-items a[hreflang="es-ES"]').prev().clone();
  54.  
  55.             $('#language-popup .w-locales-items a[hreflang="es-ES"]').parents('.popup-locale-item').hide();
  56.  
  57.             //$('#language-popup .popup-lang').text(text);
  58.             $('#language-popup .locale-flag').html(img);
  59.  
  60.             $('#language-popup').css('display', 'flex');
  61.         } else if (["en-GB"].includes(userLang) && !['/gb'].includes(location.pathname) && !localStorage.getItem("lang-popup-flag")) {
  62.             localePostfix = '/gb';
  63.  
  64.             $('.language-popup-title').html($('.language-popup-title').data('gb'));
  65.             $('.lang-popup-or-text').html($('.lang-popup-or-text').data('gb'));
  66.             $('.lang-popup-dropdown-text').html($('.lang-popup-dropdown-text').data('gb'));
  67.             $('#close-lang-popup').html($('#close-lang-popup').data('gb'));
  68.             $('#confirm-lang-redirect').html($('#confirm-lang-redirect').data('gb'));
  69.  
  70.             let text = $('#language-popup .w-locales-items a[hreflang="en-GB"]').text();
  71.             let img = $('#language-popup .w-locales-items a[hreflang="en-GB"]').prev().clone();
  72.  
  73.             $('#language-popup .w-locales-items a[hreflang="en-GB"]').parents('.popup-locale-item').hide();
  74.  
  75.             //$('#language-popup .popup-lang').text(text);
  76.             $('#language-popup .locale-flag').html(img);
  77.  
  78.             $('#language-popup').css('display', 'flex');
  79.         } else if (["en-US"].includes(userLang) && ['/gb', '/nl', '/es', '/fr'].includes(location.pathname) && !localStorage.getItem("lang-popup-flag")) {
  80.             localePostfix = '';
  81.  
  82.             let text = $('#language-popup .w-locales-items a[hreflang="en-US"]').text();
  83.             let img = $('#language-popup .w-locales-items a[hreflang="en-US"]').prev().clone();
  84.  
  85.             $('#language-popup .w-locales-items a[hreflang="en-US"]').parents('.popup-locale-item').hide();
  86.  
  87.             //$('#language-popup .popup-lang').text(text);
  88.             $('#language-popup .locale-flag').html(img);
  89.  
  90.             $('#language-popup').css('display', 'flex');
  91.         }
  92.  
  93.         $('#confirm-lang-redirect').on('click', function() {
  94.             window.location.href = window.location.origin + localePostfix
  95.         });
  96.         $('#close-lang-popup, .close-button').on('click', function() {
  97.             $('#language-popup').css('display', 'none');
  98.         });
  99.  
  100.         $(document).on('click', function(e) {
  101.             if (!$(e.target).closest('.language-popup-body').length) {
  102.                 $('#language-popup').css('display', 'none');
  103.             }
  104.             ;
  105.         });
  106.  
  107.         localStorage.setItem("lang-popup-flag", "true");
  108.     });
  109. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement