Skip to content
Snippets Groups Projects
Commit 577b69f2 authored by Jonathan Weth's avatar Jonathan Weth :keyboard:
Browse files

Use default language from settings if language is not recognizable

parent 8c1343fa
No related branches found
No related tags found
1 merge request!5Use default language from settings if language is not recognizable
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment