Jump to content

Multilanguage code possibilities in 7.1.

Recommended Posts

On 7/17/2023 at 1:06 PM, benja said:

Hey hey!
I used the code/tutorial of @bradgood to set up a multilanguage website.
Is there a chance to underline the active link? 

My website ist https://emu-apricots-sgll.squarespace.com/
and the password is: umoweb

Not sure if Brad is still active, maybe you @tuanphan can help too?
Thanks in advance!

You mean underline EN & DE on top right corner?

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
4 hours ago, tuanphan said:

You mean underline EN & DE on top right corner?

exactly, so the user can see if they're on the german page (DE) oder de english page (EN). 
It should be obvious, but it is a customer request 😄

Link to comment
On 7/19/2023 at 8:30 PM, benja said:

exactly, so the user can see if they're on the german page (DE) oder de english page (EN). 
It should be obvious, but it is a customer request 😄

First, edit this code

image.png.2c5c2a4123713477055a7d4b56f2bd9e.png

to this

 /* HOMEPAGE-LOGO LINKS TO PROPER LANGUAGE HOMEPAGE */
  if (lang == "en") {
    $('a[href="/"]').attr("href", "/en/home/");
	$('body').addClass('body-en');
  }

Next, add this to Design > Custom CSS

body:not(.body-en) .language a.lang-de {
    text-decoration: underline;
}
body.body-en .language a.lang-en {
	text-decoration: underline;
}

 

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
  • 6 months later...

Hey, I found a solution to translate all of the event elements: the months, pagination, "back to all events," etc.

Put this in the HEADER (and scroll below to see what goes in the FOOTER).

HEADER:

<!-- Translate event elements-- Squarespace circle forum and chatgpt thankyou -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://momentjs.com/downloads/moment-with-locales.js"></script>
<script>
$(document).ready(function() {
    // Translate specific terms
    $(".eventitem-sourceurl").each(function() {
        var htmlContent = $(this).html();
        $(this).html(htmlContent.replace("Source:", "Vir:"));
    });
    $(".eventitem-meta-item.eventitem-meta-cats.event-meta-item").each(function() {
        var htmlContent = $(this).html();
        $(this).html(htmlContent.replace("Posted In:", "Objavljeno v:"));
    });
    $(".eventitem-meta-item.eventitem-meta-tags.event-meta-item").each(function() {
        var htmlContent = $(this).html();
        $(this).html(htmlContent.replace("Tagged:", "Označeno:"));
    });

    // Translate dates in event pagination
    $(".events-item-pagination-date").each(function() {
        var originalText = $(this).text(); // Get the original text of the element
        var momentDate = moment(originalText, 'D MMMM'); // Parse the date
        if (momentDate.isValid()) { // Check if the date is valid
            var translatedDate = momentDate.locale('sl').format('D MMMM'); // Translate the date to Slovenian
            $(this).text(translatedDate); // Update the text with the translated date
        }
    });

    // Translate the event date
    if ($(".event-date").length) {
        var translate = moment($(".event-date").attr("datetime")).locale("sl").format('dddd, MMMM D, YYYY');
        $(".event-date").html(translate);
    
        $(".product-price")
          .contents()
          .filter(function() {
            return this.nodeType == 3;
          }).remove();
    }
});
</script>

 

 

----------

 

FOOTER

 

<!-- Translate 'Back to All Events' on Squarespace 7.1 ------------------------------------->
<script>
  window.addEventListener('DOMContentLoaded', (event) => {
    var backEvents = document.querySelector(".eventitem-backlink");
    if (backEvents) {
      backEvents.innerHTML = "Nazaj na tabore in aktivnosti";
    }
})
</script>

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.