fbpx
Skip to content
Questions & AnswersApril becomes Aprileeeeeeee
Benjamin asked 7 years ago
Hi team,  I'm using the code in my SQSP site https://hotyogatrieste.com . I have inserted the additional footer code to change some hard coded text from ENG to ITA, mostly days and dates for blog posts.  All was well until April came.  All my months translate and display fine, but April comes up as Aprile at first and then 'e's keep being added at the end, without the page reloading, they just magically appear one after another, until it ends up as Aprileeeeeeee (roughly).  I've changed the code so April = April so if you go to the site now you won't see the issue, but I'm happy to reimplement it for a time if someone needs to double check it.  Super weird...please help! jQuery('a,time').replaceText(/April/ig, "Aprile"); Ben
1 Answers
Best Answer
Dave Hilditch Staff answered 7 years ago

Hah good one – it’s seeing April inside Aprile and changing it to Aprile therefore the word keeps growing in size…
To remedy this, alter your replace to the following which will ensure it matches a whole word only (puncuation or space before/after the word):
jQuery(‘a,time’).replaceText(/\bApril\b/ig, “Aprile”);
The \b means ‘word boundary’ so putting that before and after the word you are searching for ensures it only matches whole words and not part of a word.

Benjamin replied 7 years ago

Thanks Dave, that nailed it. I’ve added that adjustment to my previous post which contains my hard coded Italian footer thus far. Excellent product and service!

We use cookies

We use cookies for various things on our site, including our on-site chat bubble (if you use it), our comment forms (if you use them) and for session handling (if you log in).

Other than that, we use cookies to identify where traffic came from to help us understand which traffic turns into sales, we use a cookie for Google Analytics traffic analysis and we use a cookie to customise adverts for our own products we think you'll be interested in.

You can read more detail in our privacy policy page. Please click 'Accept' or 'Decline' to continue.