diff --git a/calendarweek/django.py b/calendarweek/django.py index d9d72a0631f92c7aa5cfda446f03d02aec3818d0..331e45db6454bfdf6d9d7533afbb0652621844e9 100644 --- a/calendarweek/django.py +++ b/calendarweek/django.py @@ -17,6 +17,7 @@ import json import locale from typing import Any, List, Optional, Tuple +from django.conf import settings from django.http import HttpRequest, HttpResponse from django.utils.encoding import DEFAULT_LOCALE_ENCODING from django.utils.functional import lazy @@ -29,7 +30,7 @@ def i18n_day_names(loc: Optional[str] = None) -> Tuple[str]: """ Return a tuple of day names for the current locale. """ if loc is None: - loc = to_locale(get_language()) + loc = to_locale(get_language() or settings.LANGUAGE_CODE) try: return CalendarWeek.day_names(loc) @@ -41,7 +42,7 @@ def i18n_day_abbrs(loc: Optional[str] = None) -> Tuple[str]: """ Return a tuple of day name abbreviations for the current locale. """ if loc is None: - loc = to_locale(get_language()) + loc = to_locale(get_language() or settings.LANGUAGE_CODE) try: return CalendarWeek.day_abbrs(loc) @@ -53,7 +54,7 @@ def i18n_month_names(loc: Optional[str] = None) -> Tuple[str]: """ Return a tuple of month names for the current locale. """ if loc is None: - loc = to_locale(get_language()) + loc = to_locale(get_language() or settings.LANGUAGE_CODE) try: return CalendarWeek.month_names(loc) @@ -65,7 +66,7 @@ def i18n_month_abbrs(loc: Optional[str] = None) -> Tuple[str]: """ Return a tuple of month name abbreviations for the current locale. """ if loc is None: - loc = to_locale(get_language()) + loc = to_locale(get_language() or settings.LANGUAGE_CODE) try: return CalendarWeek.month_abbrs(loc)