Refs #31493 -- Replaced var with const and let in JavaScriptCatalog template.
This commit is contained in:
parent
c7e7f176c1
commit
b23216d9d0
|
@ -87,14 +87,15 @@ def get_formats():
|
||||||
|
|
||||||
js_catalog_template = r"""
|
js_catalog_template = r"""
|
||||||
{% autoescape off %}
|
{% autoescape off %}
|
||||||
(function(globals) {
|
'use strict';
|
||||||
|
{
|
||||||
var django = globals.django || (globals.django = {});
|
const globals = this;
|
||||||
|
const django = globals.django || (globals.django = {});
|
||||||
|
|
||||||
{% if plural %}
|
{% if plural %}
|
||||||
django.pluralidx = function(n) {
|
django.pluralidx = function(n) {
|
||||||
var v={{ plural }};
|
const v = {{ plural }};
|
||||||
if (typeof(v) == 'boolean') {
|
if (typeof v === 'boolean') {
|
||||||
return v ? 1 : 0;
|
return v ? 1 : 0;
|
||||||
} else {
|
} else {
|
||||||
return v;
|
return v;
|
||||||
|
@ -108,25 +109,25 @@ js_catalog_template = r"""
|
||||||
|
|
||||||
django.catalog = django.catalog || {};
|
django.catalog = django.catalog || {};
|
||||||
{% if catalog_str %}
|
{% if catalog_str %}
|
||||||
var newcatalog = {{ catalog_str }};
|
const newcatalog = {{ catalog_str }};
|
||||||
for (var key in newcatalog) {
|
for (const key in newcatalog) {
|
||||||
django.catalog[key] = newcatalog[key];
|
django.catalog[key] = newcatalog[key];
|
||||||
}
|
}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
if (!django.jsi18n_initialized) {
|
if (!django.jsi18n_initialized) {
|
||||||
django.gettext = function(msgid) {
|
django.gettext = function(msgid) {
|
||||||
var value = django.catalog[msgid];
|
const value = django.catalog[msgid];
|
||||||
if (typeof(value) == 'undefined') {
|
if (typeof value === 'undefined') {
|
||||||
return msgid;
|
return msgid;
|
||||||
} else {
|
} else {
|
||||||
return (typeof(value) == 'string') ? value : value[0];
|
return (typeof value === 'string') ? value : value[0];
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
django.ngettext = function(singular, plural, count) {
|
django.ngettext = function(singular, plural, count) {
|
||||||
var value = django.catalog[singular];
|
const value = django.catalog[singular];
|
||||||
if (typeof(value) == 'undefined') {
|
if (typeof value === 'undefined') {
|
||||||
return (count == 1) ? singular : plural;
|
return (count == 1) ? singular : plural;
|
||||||
} else {
|
} else {
|
||||||
return value.constructor === Array ? value[django.pluralidx(count)] : value;
|
return value.constructor === Array ? value[django.pluralidx(count)] : value;
|
||||||
|
@ -136,7 +137,7 @@ js_catalog_template = r"""
|
||||||
django.gettext_noop = function(msgid) { return msgid; };
|
django.gettext_noop = function(msgid) { return msgid; };
|
||||||
|
|
||||||
django.pgettext = function(context, msgid) {
|
django.pgettext = function(context, msgid) {
|
||||||
var value = django.gettext(context + '\x04' + msgid);
|
let value = django.gettext(context + '\x04' + msgid);
|
||||||
if (value.includes('\x04')) {
|
if (value.includes('\x04')) {
|
||||||
value = msgid;
|
value = msgid;
|
||||||
}
|
}
|
||||||
|
@ -144,7 +145,7 @@ js_catalog_template = r"""
|
||||||
};
|
};
|
||||||
|
|
||||||
django.npgettext = function(context, singular, plural, count) {
|
django.npgettext = function(context, singular, plural, count) {
|
||||||
var value = django.ngettext(context + '\x04' + singular, context + '\x04' + plural, count);
|
let value = django.ngettext(context + '\x04' + singular, context + '\x04' + plural, count);
|
||||||
if (value.includes('\x04')) {
|
if (value.includes('\x04')) {
|
||||||
value = django.ngettext(singular, plural, count);
|
value = django.ngettext(singular, plural, count);
|
||||||
}
|
}
|
||||||
|
@ -165,8 +166,8 @@ js_catalog_template = r"""
|
||||||
django.formats = {{ formats_str }};
|
django.formats = {{ formats_str }};
|
||||||
|
|
||||||
django.get_format = function(format_type) {
|
django.get_format = function(format_type) {
|
||||||
var value = django.formats[format_type];
|
const value = django.formats[format_type];
|
||||||
if (typeof(value) == 'undefined') {
|
if (typeof value === 'undefined') {
|
||||||
return format_type;
|
return format_type;
|
||||||
} else {
|
} else {
|
||||||
return value;
|
return value;
|
||||||
|
@ -185,8 +186,7 @@ js_catalog_template = r"""
|
||||||
|
|
||||||
django.jsi18n_initialized = true;
|
django.jsi18n_initialized = true;
|
||||||
}
|
}
|
||||||
|
};
|
||||||
}(this));
|
|
||||||
{% endautoescape %}
|
{% endautoescape %}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue