Jump to content

Multilingual site: translation of meta tags on one blog

Recommended Posts

Hi, 

I would like to ask help with the following:

On this bilingual site, I would like to translate the words "Prev" and "Next" ("Előző" and "Következő") at the bottom of blog posts under the Hungarian news (e.g. https://www.baem.hu/hirek/2023/01/30/folytattuk-az-egyuttmukodest-az-iaeste-szervezetevel), even if there is a link on them, but also if they are the first or last posts, i.e. there are without links.

There is an English news site which is also a blog, there you should keep the words "Prev" and "Next".

Thanks

Link to comment
  • Replies 2
  • Views 235
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 weeks later...

@dankamminga ,

here is the script what I'm using.

With this solution, if there is no Previous or Next link, it will not be displayed, i.e. it will not say Previous or Next. 

Maybe it helps you.

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
  $(document).ready(function() {
    var currentUrl = window.location.href;
    if (currentUrl.includes("/hirek/")) {
      var pagination = $('.pagination');
      var prevLink = pagination.find('a:contains("Prev")');
      var nextLink = pagination.find('a:contains("Next")');
      var prevText = pagination.contents().filter(function() {
        return this.nodeType === 3 && this.textContent.trim() === 'Prev /';
      });
      var nextText = pagination.contents().filter(function() {
        return this.nodeType === 3 && this.textContent.trim() === '/ Next';
      });

      if (prevLink.length > 0) {
        prevLink.text('Előző');
      } else if (prevText.length > 0) {
        prevText[0].textContent = 'Előző / ';
        prevText[0].nodeValue = ''; // kitörli ha nincs is előző
      }

      if (nextLink.length > 0) {
        nextLink.text('Következő');
      } else if (nextText.length > 0) {
        nextText[0].textContent = ' / Következő';
        nextText[0].nodeValue = ''; // kitörli ha nincs is következő
      }
    }
  });
</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.