<p>Looks like you're using the <a href="https://plugins.craftcms.com/store-hours" rel="nofollow noreferrer">Store Hours plugin</a>, right? If you check the <a href="https://github.com/craftcms/store-hours/blob/main/src/data/DayData.php#L50-L59" rel="nofollow noreferrer">source code</a>, you can see that the <code>name</code> property is already returned as a localized day name by default:</p>
<pre class="lang-php prettyprint-override"><code>return Craft::$app-&gt;getLocale()-&gt;getWeekDayName($this-&gt;dayIndex, $length);
</code></pre>
<p>So you probably don't need to do anything, the weekday name will be translated to the current site's language automatically.</p>
<p>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 <a href="https://github.com/craftcms/store-hours/blob/main/src/data/DayData.php#L18-L21" rel="nofollow noreferrer">public <code>dayIndex</code> property</a> of the <code>DayData</code> object directly. This will be an integer between 0-6, you can use that to use <code>getWeekDayName</code> function with the locale you want to translate to. Or use built-in functions:</p>
<pre class="lang-twig prettyprint-override"><code>{{ day.dateIndex|date('l') }}
</code></pre>

CC BY-SA 4.0
2022-08-02T12:34:34.553Z
2022-08-02T12:34:34.553Z
MoritzLost
<p>Maybe I'm overlooking something here, but I can't find a way to translate the week day names.</p>
<p>This is my template code:</p>
<pre><code>{% set storeHours = storeHoursGlob.storeHours.getRange(1) %}

&lt;div class=&quot;p-8 xl:container mx-auto&quot;&gt;
    &lt;h3&gt;Openingstijden&lt;/h3&gt;
    &lt;div class=&quot;grid grid-cols-7&quot;&gt;
    {% for day in storeHours %}
        &lt;div class=&quot;flex flex-col bg-white&quot;&gt;
            &lt;h2 class=&quot;text-[#339F7F]&quot;&gt;{{ day.name }}&lt;/h2&gt;
            &lt;dd&gt;
            {% if day.isBlank %}
                Gesloten
            {% else %}
                {{ day.open|date('H:i') }} - {{ day.close|date('H:i') }}
            {% endif %}
            &lt;/dd&gt;
        &lt;/div&gt;
    {% endfor %}
    &lt;/div&gt;
&lt;/div&gt;
</code></pre>
<p>Anyone who can point me in the right direction?
Thank you very much in advance!</p>

CC BY-SA 4.0
2022-08-02T11:43:10.360Z
What exactly is `storeHoursGlob`?
Ben Croker
CC BY-SA 4.0
2022-08-02T13:35:19.703Z
Maybe Glob = global?
RitterKnight
<craft3><localization>
Way to translate days in CraftCMS 'Opening Hours'
# Way to translate days in CraftCMS 'Opening Hours'

(Asked by: username_0 on 2022-08-02)

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) %}


    Openingstijden
    
    {% for day in storeHours %}
        
            {{ day.name }}
            
            {% if day.isBlank %}
                Gesloten
            {% 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!

**Tags:** craft3, localization
> **Comments:**
> **username_1**: What exactly is `storeHoursGlob`?  
> **username_2**: Maybe Glob = global?  

---

## 1 answers

### Answer by username_3 on 2022-08-02. Score: 2

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') }}


---

