aboutsummaryrefslogtreecommitdiff
path: root/ext/js/language/translator.js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js/language/translator.js')
-rw-r--r--ext/js/language/translator.js16
1 files changed, 14 insertions, 2 deletions
diff --git a/ext/js/language/translator.js b/ext/js/language/translator.js
index 1abf9f4e..056ff3a7 100644
--- a/ext/js/language/translator.js
+++ b/ext/js/language/translator.js
@@ -866,7 +866,7 @@ class Translator {
dictionaryIndex,
dictionaryPriority,
hasReading,
- frequency
+ this._convertFrequency(frequency)
));
}
}
@@ -920,7 +920,7 @@ class Translator {
dictionaryIndex,
dictionaryPriority,
character,
- data
+ this._convertFrequency(data)
));
}
break;
@@ -971,6 +971,18 @@ class Translator {
});
}
+ _convertFrequency(value) {
+ switch (typeof value) {
+ case 'number':
+ return value;
+ case 'string':
+ value = Number.parseFloat(value);
+ return Number.isFinite(value) ? value : 0;
+ default:
+ return 0;
+ }
+ }
+
// Helpers
_getNameBase(name) {