Maybe I'm overlooking something here, but I can't find a way to translate the week day names.

This is my template code:

{% set storeHours = storeHoursGlob.storeHours.getRange(1) %}

<div class="p-8 xl:container mx-auto">
    <div class="grid grid-cols-7">
    {% for day in storeHours %}
        <div class="flex flex-col bg-white">
            <h2 class="text-[#339F7F]">{{ day.name }}</h2>
            {% if day.isBlank %}
            {% else %}
                {{ day.open|date('H:i') }} - {{ day.close|date('H:i') }}
            {% endif %}
    {% endfor %}

Anyone who can point me in the right direction? Thank you very much in advance!

  • What exactly is storeHoursGlob?
    – Ben Croker
    Commented Aug 2, 2022 at 11:43
  • Maybe Glob = global? Commented Aug 2, 2022 at 13:35

1 Answer 1


Looks like you're using the Store Hours plugin, right? If you check the source code, you can see that the name property is already returned as a localized day name by default:

return Craft::$app->getLocale()->getWeekDayName($this->dayIndex, $length);

So you probably don't need to do anything, the weekday name will be translated to the current site's language automatically.

If this doesn't work for you or you need to translate the day name to a different language for some reason, you can access the public dayIndex property of the DayData object directly. This will be an integer between 0-6, you can use that to use getWeekDayName function with the locale you want to translate to. Or use built-in functions:

{{ day.dateIndex|date('l') }}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.