Skip to content

Instantly share code, notes, and snippets.

@karfau
Last active June 4, 2017 19:17
Show Gist options
  • Save karfau/17f58a5770b0b60b181fc8ad897f1f99 to your computer and use it in GitHub Desktop.
Save karfau/17f58a5770b0b60b181fc8ad897f1f99 to your computer and use it in GitHub Desktop.
Grav CMS Solution #X for localized date parts.

Problem:

Described here: https://learn.getgrav.org/cookbook/twig-recipes#displaying-a-translated-month

Usage

put this file into user/languages of your site (create if it doesn't exist). enables names of dates translated to german by appending |t.

example:

day of the week:
short {{ page.date|date('D')|t }},
long  {{ page.date|date('l')|t }}

month:
short {{ page.date|date('M')|t }},
long  {{ page.date|date('F')|t }}
  • assumes PHP returns english letters.
  • for german not all keys are needed, because some are equal and |t just returns the input
  • feel free to add more languages
January: Januar
February: Februar
March: März
Mar: Mär
May: Mai
June: Juni
July: Juli
October: Oktober
Oct: Okt
December: Dezember
Dec: Dez
Monday: Montag
Mon: Mo
Thuesday: Dienstag
Thu: Di
Wednesday: Mittwoch
Wed: Mi
Thursday: Donnerstag
Thu: Do
Friday: Freitag
Fri: Fr
Saturday: Sonnabend
Sat: Sa
Sunday: Sonntag
Sun: So
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment