Added the title_case filter and replaced the title filter with the title_case filter to display titles in American English.

This commit is contained in:
2020-08-03 22:31:13 +08:00
parent 3babe8bc1f
commit 66f57b7b0d
13 changed files with 77 additions and 63 deletions

@ -20,6 +20,7 @@
"""
from datetime import date
import titlecase
from django import template
from django.template import defaultfilters
from django.urls import reverse
@ -217,3 +218,16 @@ def smart_month(value):
if value.year == year and value.month == month:
return gettext("Last Month")
return defaultfilters.date(value, "Y/n")
@register.filter
def title_case(value):
"""Formats the title in a proper American-English case.
Args:
value (str): The title.
Returns:
str: The title in a proper American-English case.
"""
return titlecase.titlecase(value)