Fix missing arg handling in html10n.js

changelog-187
ilmar 2020-11-05 11:36:22 +02:00 committed by John McLear
parent 405e3e3e19
commit d5c5ca224b
2 changed files with 6 additions and 4 deletions

View File

@ -31,6 +31,8 @@
.gritter-item .gritter-content {
flex: 1 auto;
text-align: center;
width: 95%;
overflow-wrap: break-word;
}
.gritter-item .gritter-close {
@ -48,4 +50,4 @@
right: 1rem;
transform: none;
}
}
}

View File

@ -779,16 +779,16 @@ window.html10n = (function(window, document, undefined) {
function substArguments(str, args) {
var reArgs = /\{\{\s*([a-zA-Z\.]+)\s*\}\}/
, match
var translations = html10n.translations;
while (match = reArgs.exec(str)) {
if (!match || match.length < 2)
return str // argument key not found
var arg = match[1]
, sub = ''
if (arg in args) {
if (args && arg in args) {
sub = args[arg]
} else if (arg in translations) {
} else if (translations && arg in translations) {
sub = translations[arg]
} else {
console.warn('Could not find argument {{' + arg + '}}')