Docs    Facebook    Customizations

Translate the months of the date using JavaScript

In the WordPress plugin the date will be displayed in whichever language your WordPress installation is in. Sometimes you may have multiple feeds on a site though and each one needs to be in a different language, or you may be using the PHP Standalone version, and so may need to translate the months of the date manually. You can do this by using the custom JavaScript snippet below:

$('.cff-start-date, .cff-end-date').each(function(){
  var mapObj = {
     Jan:"Translated Jan",
     Feb:"Translated Feb",
     Mar:"Translated Mar",
     Apr:"Translated Apr",
     May:"Translated May",
     Jun:"Translated Jun",
     Jul:"Translated Jul",
     Aug:"Translated Aug",
     Sep:"Translated Sep",
     Oct:"Translated Oct",
     Nov:"Translated Nov",
     Dec:"Translated Dec"
  
  };
  newText = $(this).text().replace(/Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec/gi, function(matched){
    return mapObj[matched];
  });

  $(this).text(newText);
});

If you’re displaying the full month names, then you would need to change the “Jan”, “Feb”, “Mar”, etc, to be the full month names; “January”, “February”, etc.

Note: In the WordPress plugin you’d need to add the JavaScript to your site using a custom JavaScript plugin. For further information see our documentation here. In the PHP Standalone version you’d need to add it to your website’s JavaScript file, or to the bottom of your page within <script> tags.

support

Couldn’t find your answer in the docs?

Contact Support

Was this article helpful?