Webflow sync, pageviews & more.
NEW

How can I ensure that the dates and times in the dynamic collections on my Webflow site appear correctly in French and Arabic? Additionally, how can I add an RTL code for my Arabic site?

TL;DR
  • Use JavaScript with toLocaleDateString() to format CMS dates for French or Arabic.
  • Set the HTML lang attribute in Page Settings to "fr" or "ar" for proper localization.
  • Apply RTL layout for Arabic using custom code to set dir="rtl" and related CSS.
  • If available, use Webflow Localization to manage language-specific formats and RTL automatically.

To display dates/times in French and Arabic correctly and ensure RTL layout for Arabic, you need to localize both text display and layout direction using Webflow's native tools and optional custom code.

1. Format Dates and Times Based on Locale

  • Webflow CMS stores date/time fields in a universal format, but does not natively support locale-specific formatting (like French or Arabic).
  • Use custom JavaScript with the toLocaleDateString() method to format dates based on language.

Example workaround:

  • Add a span with a data-date attribute inside a collection list (e.g., <span class="localized-date" data-date="2024-06-05T00:00:00Z"></span>).
  • In Page Settings > Before tag, insert custom JavaScript that:
  • Selects all .localized-date elements.
  • Reads the ISO date string.
  • Replaces the content using new Date().toLocaleDateString('fr-FR') or 'ar-EG'.

2. Localize the Site Language

  • In Page Settings, set the page’s HTML lang attribute:
  • For French pages: Set to fr
  • For Arabic pages: Set to ar

This improves accessibility, tells the browser which language to render, and helps assistive technologies.

3. Add RTL Code for Arabic Language Pages

Webflow does not auto-apply RTL, so you must define it manually using the following methods:

  • Method A: Add dir="rtl" to the <html> or <body> tag — not possible in Webflow directly, so instead:

  • Method B: Add a custom attribute and CSS rule:

  • Go to Page Settings for your Arabic page.

  • Add a custom script (Before </body> tag):

    ```javascript
    document.body.setAttribute("dir", "rtl");
    ```

  • Or define a class on body (e.g., rtl), then in Site Settings > Custom Code or <style> block:

    • Add CSS:

      ```
      body[dir="rtl"] {
      direction: rtl;
      text-align: right;
      }
      ```

  • Ensure text and components respect RTL flow by aligning items correctly in the Webflow Designer using right-aligned elements, flex, or grid with reversed direction.

4. Use Webflow Localization (If Available on Your Plan)

  • If you're on a paid Workspace plan that includes Webflow Localization, you can:
  • Set different languages and regional formats per locale.
  • Configure language-specific date formats visually.
  • Apply RTL setting automatically for Arabic using locale settings.

Summary

To display dates properly and support RTL:

  • Use JavaScript to format CMS dates with toLocaleDateString('fr-FR') or ('ar-EG').
  • Set page language (lang) in Page Settings.
  • Apply RTL with custom code by setting dir="rtl" dynamically.
  • If using Webflow Localization, configure locale-specific formatting and layout direction within the platform.
Rate this answer

Other Webflow Questions