Jump to content

Button for multilingual site

Recommended Posts

Site URL: https://www.patricialindner.com/

I used code to make my site multilingual. I would like to have two buttons to switch languages, english and german. I would like the buttons to be transparent with just a white outline and white text that says EN and DE. Can anyone help with this? I would like these buttons to be in line with the nav links if possible. site password is Patricia. Thanks!

Link to comment
19 hours ago, JennWalker said:

Site URL: https://www.patricialindner.com/

I used code to make my site multilingual. I would like to have two buttons to switch languages, english and german. I would like the buttons to be transparent with just a white outline and white text that says EN and DE. Can anyone help with this? I would like these buttons to be in line with the nav links if possible. site password is Patricia. Thanks!

First, change your scripts

From:

/*setup language switcher*/
$('body').prepend('<div class="language"><a href="/en/home" class="lang-en">English</a> | <a href="/de/home/" class="lang-de">Deutsch</a></div>');

To: 


/*setup language switcher*/
$('body').prepend('<div class="language"><a href="/en/home" class="lang-en">EN</a> | <a href="/de/home/" class="lang-de">DE</a></div>');

Secondly, add to the Custom Css

.language a {
    border: 1px solid #fff !important;
    padding: 5px;
}

 

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date format)
💫 Animated Buttons (Referral URL)
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Here is the result 

image.thumb.png.68643ebbe77e3b129d269ba64c10f7f5.png

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date format)
💫 Animated Buttons (Referral URL)
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

@JennWalker Add 2 sections in Footer for 2 languages

  • Top section for English
  • Bottom section for DE

Next, find this code

if (lang == "de") {
    $('a[href="/"]').attr("href", "/de/home/");
  }

edit it to

if (lang == "de") {
    $('a[href="/"]').attr("href", "/de/home/");
	$('body').addClass('body-de');
  }

Next, add this to Code Injection > Header

<style>
  body.body-de footer.sections section:nth-child(1) {
  	display: none;
  }
  body:not(.body-de) footer.sections section:nth-child(2) {
  	display: none;
  }
</style>

 

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment
16 hours ago, tuanphan said:

@JennWalker Add 2 sections in Footer for 2 languages

  • Top section for English
  • Bottom section for DE

Next, find this code

if (lang == "de") {
    $('a[href="/"]').attr("href", "/de/home/");
  }

edit it to

if (lang == "de") {
    $('a[href="/"]').attr("href", "/de/home/");
	$('body').addClass('body-de');
  }

Next, add this to Code Injection > Header

<style>
  body.body-de footer.sections section:nth-child(1) {
  	display: none;
  }
  body:not(.body-de) footer.sections section:nth-child(2) {
  	display: none;
  }
</style>

 

Thank you so much! That worked great. The only issue is the disclaimer is now pushed up on the button. Not a big deal, I can just delete it if needed but do you know how to fix it easily?

image.thumb.png.418702aa9ec0565d848aca75b2daaeb9.png

Link to comment
On 9/30/2021 at 7:26 AM, JennWalker said:

Thank you so much! That worked great. The only issue is the disclaimer is now pushed up on the button. Not a big deal, I can just delete it if needed but do you know how to fix it easily?

image.thumb.png.418702aa9ec0565d848aca75b2daaeb9.png

It looks fine to me. Do you use Mac or Windows?

Email me if you have need any help (free, of course.). Answer within 24 hours. 
Or send to forum message

Contact Customer Care - Learn CSS - Buy me a coffee (thank you!)

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • 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.