zwbetz-gh / cupper-hugo-theme

An accessibility-friendly Hugo theme, ported from the original Cupper project.
https://cupper-hugo-theme.netlify.app/
MIT License
301 stars 190 forks source link

Date translation #51

Closed ellypsis closed 3 years ago

ellypsis commented 3 years ago

Is your feature request related to a problem? Please describe. I'm trying to use this method to translate months.

Describe the solution you'd like How to incorporate this solution in the template? Can I use a solution without modification on theme files? (update in mind)

Describe alternatives you've considered Incorporate a translation method with i18n config for time-date translation, as Go doesn't support it yet

Additional context I'm still a newbie in coding, but have some knowledge. Thanks for helping me!

zwbetz-gh commented 3 years ago

Hi @ellypsis. You can do your date translation work by overriding this template file

ellypsis commented 3 years ago

Thank you for your quick answer. I didn't know (read enough...) I could do that! I founded the right file to modify but didn't know how to do it. Finally made it works.

    <div class="date">
      <strong>{{ T "publish_date" }} </strong>{{ .Date.Day }} {{ index $.Site.Data.mois (printf "%d" .Date.Month) }} {{ .Date.Year }}
      {{ with .Lastmod }}
        {{ if gt . $publishDate }}
          <br>
          <strong>{{ T "last_updated" }} </strong>{{ .Lastmod.Day }} {{ index $.Site.Data.mois (printf "%d" .Lastmod.Month) }} {{ .Lastmod.Year }}
        {{ end }}
      {{ end }}
    </div>

You did a really great work with this forked theme. Really like it :+1:

zwbetz-gh commented 3 years ago

Glad to hear you found a solution. And thank you for the kind words