Skip to content
Snippets Groups Projects

Use default language from settings if language is not recognizable

Merged Jonathan Weth requested to merge fix/default-language into master
1 file
+ 5
4
Compare changes
  • Side-by-side
  • Inline
+ 5
4
@@ -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)
Loading