forked from CGM_Public/pretix_original
Refactor stubs for gettext JS function (#5170)
This commit is contained in:
23
src/pretix/static/pretixbase/js/gettextstub.js
Normal file
23
src/pretix/static/pretixbase/js/gettextstub.js
Normal file
@@ -0,0 +1,23 @@
|
||||
// The actual gettext implementation is loaded asynchronously with the translation
|
||||
function gettext(msgid) {
|
||||
if (typeof django !== 'undefined' && typeof django.gettext !== 'undefined') {
|
||||
return django.gettext(msgid);
|
||||
}
|
||||
return msgid;
|
||||
}
|
||||
|
||||
function ngettext(singular, plural, count) {
|
||||
if (typeof django !== 'undefined' && typeof django.ngettext !== 'undefined') {
|
||||
return django.ngettext(singular, plural, count);
|
||||
}
|
||||
return plural;
|
||||
}
|
||||
|
||||
function interpolate(fmt, object, named) {
|
||||
if (named) {
|
||||
return fmt.replace(/%\(\w+\)s/g, function(match){return String(obj[match.slice(2,-2)])});
|
||||
} else {
|
||||
return fmt.replace(/%s/g, function(match){return String(obj.shift())});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user