Language markup that can show dynamic dates in different languages

Example for FR, for landing page only (http://cdl.webflow.io/fr/home).
Insert into page settings last custom code field.

Do the same for the other pages, but change the variables.

<script>
var Webflow = Webflow || [];
Webflow.push(function() {
  $.getScript('https://momentjs.com/downloads/moment-with-locales.min.js', 
  function() {

    // Get all the classes here
    $('.p-t-11').each(function() {

      // Try to parse the contents into a date using this format
      var d = moment($(this).text(), "dddd, MMMM D, YYYY");

      // If it's a valid date
      if(d.isValid()) {

        // Convert to another locale, and in a new format
        var newDate = d.locale('fr').format("dddd, MMMM D, YYYY");

        // Replace contents with the new date
        $(this).text(newDate);
      }

    }); // End each
  }); // End getScript

});
</script>

Also, feel free to contact me for further code help and/or customization of third-party plugins

7 Likes