MyListing Club

Replace Text That Loco Translate Can't Reach

Building better MyListing websites. One code snippet at a time.

Overview

The Replace Text That Loco Translate Can’t Reach code snippet provides additional functionality for MyListing websites.

There are external elements like Mapbox, Google Maps, etc. that plugins like Loco Translate cannot reach and in those instances we need to change text using a script.

Implementation

  1. Grab the code snippet.
  2. Follow the provided instructions.
  3. Save your changes.
				
					//// INSTRUCTIONS: 
//// Copy and paste the code snippet below into Theme Tools > Theme Options > Custom Code > JavaScript.

--------------------------- CODE SNIPPET IS BELOW THIS LINE --------------------------- 

// REPLACE TEXT THAT LOCO TRANSLATE CAN'T REACH
jQuery(document).ready(function ($) {
  $(".item-property").each(function () {
    var text = $(this).text();
    $(this).text(
      text.replace("enter-your-original-text", "enter-your-new-text")
    );
  });
});