Skip to content
Snippets Groups Projects
Commit 75077b8b authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Let JS function return a full script

parent bdcb0c7a
No related branches found
Tags 0.2.1
No related merge requests found
...@@ -2,7 +2,7 @@ import json ...@@ -2,7 +2,7 @@ import json
import locale import locale
from typing import Tuple from typing import Tuple
from django.http import HttpRequest, JsonResponse from django.http import HttpRequest, HttpResponse
from django.utils.encoding import DEFAULT_LOCALE_ENCODING from django.utils.encoding import DEFAULT_LOCALE_ENCODING
from django.utils.functional import lazy from django.utils.functional import lazy
from django.utils.translation import get_language, to_locale from django.utils.translation import get_language, to_locale
...@@ -78,17 +78,21 @@ def i18n_month_abbr_choices() -> Tuple[Tuple[int, str]]: ...@@ -78,17 +78,21 @@ def i18n_month_abbr_choices() -> Tuple[Tuple[int, str]]:
return enumerate(i18n_month_abbrs()) return enumerate(i18n_month_abbrs())
def i18n_json_data(request: HttpRequest) -> JsonResponse: def i18n_js(request: HttpRequest) -> HttpResponse:
""" Deliver a JSON file containing JS representations of the current locale's """ Deliver a JS file containing JS representations of the current locale's
calendar translations. """ calendar translations. """
return JsonResponse( return HttpResponse(
{ "var calendarweek_i18n = "
"day_names": i18n_day_names(), + json.dumps(
"day_abbrs": i18n_day_abbrs(), {
"month_names": i18n_month_names(), "day_names": i18n_day_names(),
"month_abbrs": i18n_month_abbrs(), "day_abbrs": i18n_day_abbrs(),
} "month_names": i18n_month_names(),
"month_abbrs": i18n_month_abbrs(),
}
),
content_type="text/javascript",
) )
......
[tool.poetry] [tool.poetry]
name = "calendarweek" name = "calendarweek"
version = "0.2.0" version = "0.2.1"
description = "Utilities for working with calendar weeks in Python and Django" description = "Utilities for working with calendar weeks in Python and Django"
authors = ["Dominik George <nik@naturalnet.de>", "Jonathan Weth <git@jonathanweth.de>"] authors = ["Dominik George <nik@naturalnet.de>", "Jonathan Weth <git@jonathanweth.de>"]
license = "MIT" license = "MIT"
......
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