Jump to content

AshleyAndrews

Circle Member
  • Posts

    0
  • Joined

  • Last visited

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

AshleyAndrews's Achievements

Level 1

Level 1 (1/20)

0

Reputation

  1. Hi Bangank36,

    I saw you helped someone add a language switcher to their squarespace site and wondered if you could also help me? I have two websites and on one I want to link to the other. I would like a single flag (Russian) top right to link to a url.  Could you please help me, I am going crazy trying to find the solution. Below is the code from the forum entry. Many many thanks in advance. 

     

    <style>
    	.language {
    	  position: absolute;
    	  z-index: 999;
    	  top: -20px;
    	  left: 0;
    	  display: inline-block;
    	}
    	.language a {
    	  border: 1px solid #000;
    	  margin: 0 5px;
    	  width: 40px;
    	  height: 20px;
    	  display: inline-block;
    	  background-position: center top;
    	  float: left;
    	  text-indent: -999999px;
    	  color: transparent;
    	}
    	.language [href="/en/home/"] {
    	  background: url(https://restcountries.eu/data/gbr.svg) no-repeat;
    	  background-size: cover;  
    	}
    
    	.language [href="/de/home"] {
    	  background: url(https://restcountries.eu/data/deu.svg) no-repeat;
    	  background-size: cover;
    	  width: 33px
    	}
    
    </style>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
    <script>
    $(function() { 
      /* SETUP MULTI-LANGUAGE */
      var defaultLanguage = 'de';
      var lang = location.pathname.split("/")[1];
      var defaultClass = 'lang-'+defaultLanguage+'';
      var itemParent = "nav [class*='collection'],nav [class*='folder'],nav [class*='index'],nav [class*='group']";
      if (lang == "" || lang.length > 2 ){
        var lang = defaultLanguage;
      }
    
      /* ADD LANGUAGE CLASSES */
      $('a[href="/"]').addClass('lang-'+defaultLanguage+'').parents(itemParent).addClass('lang-'+defaultLanguage+'');
      $('nav a:link:not([href^="http://"]):not([href^="https://"])').each(function () {
        var langType = $(this).attr('href').split("/")[1];
        var multiLanguageClass = 'multilanguage lang-' + langType + '';
        if (undefined !== langType && langType.length <= 2) 
          $(this).addClass(multiLanguageClass).parents(itemParent).addClass(multiLanguageClass);
      });
      $('nav button').each(function () {
        var langTypeFolder = $(this).attr('data-controller-folder-toggle').split("/")[0];
        var multiLanguageClass = 'multilanguage lang-' + langTypeFolder + '';
        if (undefined !== langTypeFolder && langTypeFolder.length <= 2) 
          $(this).addClass(multiLanguageClass);
      });
    
      /* HOMEPAGE-LOGO LINKS TO PROPER LANGUAGE HOMEPAGE */
      if (lang == "en") {
        $('a[href="/"]').attr("href", "/en/home/");
      }
    
      /* ADD EXCLUSION NAV ITEMS */
      $('.exclude-me,.exclude-me a').addClass('exclude');
      $('.sqs-svg-icon--list a,.SocialLinks-link').addClass('exclude');
    
      /* REMOVE OTHER LANGUAGES AND KEEP EXCLUDED ITEMS */
      $('.multilanguage:not(".lang-'+lang+',.exclude")').remove();
    });
    
    </script>
    <script>
    /*setup language switcher*/
    $('.header-title-text').prepend('<div class="language"><a href="/de/home" class="lang-en">Deutsch</a><a href="/en/home/" class="lang-es">English</a></div>');
    </script>
    1. Show previous comments  5 more
    2. Beyondspace

      Beyondspace

      sorry been busy these days, let's place question on new topic

    3. AshleyAndrews

      AshleyAndrews

      Hi Bangank36, When you say 'let's place question on new topic' do i need to do anything?

    4. AshleyAndrews

      AshleyAndrews

      Hi Bangank36,

      Happy New Year, hope you had a good one!

      Please let me know what do I need to do to make this request for help happen, I really want/need to sort this for my client. Any chance you can help? Please let me know.

       

       

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.