Skip to content

Commit

Permalink
feat(i18n): custom date formats per locale
Browse files Browse the repository at this point in the history
  • Loading branch information
thekaveman committed Apr 26, 2024
1 parent 01c52c9 commit cb42683
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 0 deletions.
Empty file added benefits/locale/__init__.py
Empty file.
Empty file added benefits/locale/en/__init__.py
Empty file.
2 changes: 2 additions & 0 deletions benefits/locale/en/formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#date-and-time-formatting-specifiers
DATE_FORMAT = "F j, Y"
Empty file added benefits/locale/es/__init__.py
Empty file.
5 changes: 5 additions & 0 deletions benefits/locale/es/formats.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Both “d” and “e” are backslash-escaped, because otherwise each is a format string
# that displays the day and the timezone name, respectively.
# Instead we want the literal word "de"
# https://docs.djangoproject.com/en/5.0/ref/templates/builtins/#date-and-time-formatting-specifiers
DATE_FORMAT = r"j \d\e F \d\e Y"
5 changes: 5 additions & 0 deletions benefits/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@ def RUNTIME_ENVIRONMENT():
TIME_ZONE = "UTC"
USE_TZ = True

# https://docs.djangoproject.com/en/5.0/topics/i18n/formatting/#creating-custom-format-files
FORMAT_MODULE_PATH = [
"benefits.locale",
]

# Static files (CSS, JavaScript, Images)

STATIC_URL = "/static/"
Expand Down

0 comments on commit cb42683

Please sign in to comment.