Why doesn't my date translation code work for French language?

Topic summary

A developer is trying to translate an expected delivery date display on a Shopify product page into French, but the date output remains in English despite using language detection logic.

The Core Issue:

  • The Liquid template code {{ 'now' | date: "%s" | plus: seconds | date: "%a, %b %d" }} outputs English month/day names (“Mon, Jan 01”) even when the French language branch executes
  • The developer assumed Shopify’s date filter would automatically translate based on locale, but this doesn’t happen

Solution Provided:

  • Shopify’s date filter does not automatically translate month/day names into other languages
  • Manual string replacement is required: parse the date output and replace English terms with French equivalents (e.g., replace: 'January', 'janvier')
  • Alternative: use numbered date formats (YYYY-MM-DD) which are language-neutral
  • Referenced resources include Shopify community threads and tutorials on translating Liquid date strings

Additional Consideration:

  • Using 'now' in templates may not update on every page view due to caching, which could be problematic for dynamic delivery date displays
Summarized with AI on November 13. AI used: claude-sonnet-4-5-20250929.

Good day,

I have written a code on my product page to display an expected delivery date. I’m translating my shop into French, so I would like to translate this part, too.

According to what I read, the date is supposed to translate automatically, but it doesn’t.

Here is the whole script for both languages:

    {% if localization.language.endonym_name contains 'fr' %}
      {% assign message = 'Dépêchez-vous, plus que quelques restants!' %}
      {% if target.inventory_quantity > 3 %}
        {% assign min = 1 %}
        {% assign max = 3 %}
        {% assign diff = max | minus: min %}
        {% assign randomNumber = "now" | date: "%N" | modulo: diff | plus: min %}
          {% if randomNumber == 1 %}
           {% assign message = 'Disponible. Envoyé depuis Hamilton, Ontario' %}
          {% elsif randomNumber == 2 %}
            {% assign todayDate = 'now' | date: "%w" %}
              {% unless todayDate == "4" %}
                {% assign seconds = 3 | times: 24 | times: 60 | times: 60 %}
                {% capture message %}Recevez-le le {{ 'now' | date: "%s" | plus: seconds | date: "%a, %b %d" }} (Express){% endcapture %}
              {% else %}
                {% assign seconds = 4 | times: 24 | times: 60 | times: 60 %}
                {% capture message %}Recevez-le le {{ 'now' | date: "%s" | plus: seconds | date: "%a, %b %d" }} (Express){% endcapture %}            
              {% endunless %}
          {% else %}
            {% assign message = 'Envoyé depuis Hamilton, Ontario' %}
          {% endif %}
      {% endif %}
    {% else %}      
      {% assign message = 'Act fast, only a few kits left!' %}
      {% if target.inventory_quantity > 3 %}
        {% assign min = 1 %}
        {% assign max = 3 %}
        {% assign diff = max | minus: min %}
        {% assign randomNumber = "now" | date: "%N" | modulo: diff | plus: min %}
          {% if randomNumber == 1 %}
           {% assign message = 'In-stock. Ships from California' %}
          {% elsif randomNumber == 2 %}
            {% assign todayDate = 'now' | date: "%w" %}
              {% unless todayDate == "4" %}
                {% assign seconds = 3 | times: 24 | times: 60 | times: 60 %}
                {% capture message %}Get it by {{ 'now' | date: "%s" | plus: seconds | date: "%a, %b %d" }} (Expedited){% endcapture %}
              {% else %}
                {% assign seconds = 4 | times: 24 | times: 60 | times: 60 %}
                {% capture message %}Get it by {{ 'now' | date: "%s" | plus: seconds | date: "%a, %b %d" }} (Expedited){% endcapture %}            
              {% endunless %}
          {% else %}
            {% assign message = 'Ships from San Bernadino, CA' %}
          {% endif %}
      {% endif %}
    {% endif %}

And here is the code used to display it on the page:

    {% if product.selected_or_first_available_variant.available %}
      <span class="badge color-{{ settings.sale_badge_color_scheme }}{% unless display_custom_badge %} hidden{% endunless %} badge_msg" aria-hidden="true">
        {{ message }}
      </span>
    {% endif %}

This code “{{ ‘now’ | date: “%s” | plus: seconds | date: “%a, %b %d” }}” doesn’t translate.

I still get: “Recevez-le le Mon, Jan 01 (Express)” in french.

Do you have any advice on how I can solve the problem?

Thanks in advance for your assistance!

Cheers,

Gaétan

Hi @El_Bouck

Use reduced test cases first when seeking help , then main walls of text second after a simple problem statement. That’s a lot of branching logic for someone else to get through to tell if you’ve made a conditional mistake, or it’s just the translation system not working like assumed.

Simplify the noise and test:

{% if localization.language.endonym_name contains 'fr' %}
 {{ 'now' | date: "%s" | plus: seconds | date: "%a, %b %d" }}
{% endif %}

Afaik you generally need to parse strings, or use even more translation keys to pull this off in liquid with the date objects. Most guides on this are only about swapping around the format strings(mm-dd vs dd-mm) and NOT about actually translating the human read word values between languages.

By parsing I mean: {{ date: ‘%d %B %Y’ | replace: ‘January’, ‘januari’ }}

I.e. https://community.shopify.com/c/technical-q-a/change-date-format-overall-blog-view/m-p/1414976 or https://freakdesign.com.au/blogs/news/translate-a-liquid-date-string-in-shopify

What did you read that said it translates automatically, provide references when assumptions are in play but outputs don’t match expectations.

Relevant info from shopify partner blog:

It’s important to note that the output of date isn’t translated into other languages. To ensure dates are universal, consider using a numbered format like 2019-09-14.> > from https://www.shopify.com/partners/blog/liquid-date-format

:bomb: BE AWARE when using ‘now’, generally not a problem in cart template but ?:

The timestamp will reflect the time that the Liquid was last rendered. Because of this, the timestamp might not be updated for every page view, depending on the context and caching.> > from https://shopify.dev/docs/api/liquid/filters/date