Debian Codegraph @

js_tests/admin/jsi18n-mocks.test.js

raw
1 'use strict';
2 {
3 const globals = this;
4 const django = globals.django;
5
6 django.pluralidx = function(count) { return (count === 1) ? 0 : 1; };
7
8 /* gettext identity library */
9
10 django.gettext = function(msgid) { return msgid; };
11 django.ngettext = function(singular, plural, count) {
12 return (count === 1) ? singular : plural;
13 };
14 django.gettext_noop = function(msgid) { return msgid; };
15 django.pgettext = function(context, msgid) { return msgid; };
16 django.npgettext = function(context, singular, plural, count) {
17 return (count === 1) ? singular : plural;
18 };
19
20 django.interpolate = function(fmt, obj, named) {
21 if (named) {
22 return fmt.replace(/%\(\w+\)s/g, function(match) {
23 return String(obj[match.slice(2, -2)]);
24 });
25 } else {
26 return fmt.replace(/%s/g, function(match) {
27 return String(obj.shift());
28 });
29 }
30 };
31
32 /* formatting library */
33
34 django.formats = {
35 "DATETIME_FORMAT": "N j, Y, P",
36 "DATETIME_INPUT_FORMATS": [
37 "%Y-%m-%d %H:%M:%S",
38 "%Y-%m-%d %H:%M:%S.%f",
39 "%Y-%m-%d %H:%M",
40 "%Y-%m-%d",
41 "%m/%d/%Y %H:%M:%S",
42 "%m/%d/%Y %H:%M:%S.%f",
43 "%m/%d/%Y %H:%M",
44 "%m/%d/%Y",
45 "%m/%d/%y %H:%M:%S",
46 "%m/%d/%y %H:%M:%S.%f",
47 "%m/%d/%y %H:%M",
48 "%m/%d/%y"
49 ],
50 "DATE_FORMAT": "N j, Y",
51 "DATE_INPUT_FORMATS": [
52 "%Y-%m-%d",
53 "%m/%d/%Y",
54 "%m/%d/%y"
55 ],
56 "DECIMAL_SEPARATOR": ".",
57 "FIRST_DAY_OF_WEEK": 0,
58 "MONTH_DAY_FORMAT": "F j",
59 "NUMBER_GROUPING": 3,
60 "SHORT_DATETIME_FORMAT": "m/d/Y P",
61 "SHORT_DATE_FORMAT": "m/d/Y",
62 "THOUSAND_SEPARATOR": ",",
63 "TIME_FORMAT": "P",
64 "TIME_INPUT_FORMATS": [
65 "%H:%M:%S",
66 "%H:%M:%S.%f",
67 "%H:%M"
68 ],
69 "YEAR_MONTH_FORMAT": "F Y"
70 };
71
72 django.get_format = function(format_type) {
73 const value = django.formats[format_type];
74 if (typeof value === 'undefined') {
75 return format_type;
76 } else {
77 return value;
78 }
79 };
80
81 /* add to global namespace */
82 globals.pluralidx = django.pluralidx;
83 globals.gettext = django.gettext;
84 globals.ngettext = django.ngettext;
85 globals.gettext_noop = django.gettext_noop;
86 globals.pgettext = django.pgettext;
87 globals.npgettext = django.npgettext;
88 globals.interpolate = django.interpolate;
89 globals.get_format = django.get_format;
90 };