mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 19:53:36 +00:00
Fix exception on translation of objects
Sometimes, the content of translations[module.name][key] is not a string but an entire object. It cause a crash on template.replace(...) of createStringFromTemplate(...). It is currently the case of MMM-Voice-Control and the previous commit have broked this module (10 month ago... I am surprised to be the first founded it)
This commit is contained in:
parent
20823bfc87
commit
0388f5787a
@ -126,6 +126,9 @@ var Translator = (function() {
|
|||||||
// variables: {timeToWait: "2 hours", work: "painting"}
|
// variables: {timeToWait: "2 hours", work: "painting"}
|
||||||
// to: "Please wait for 2 hours before continuing with painting."
|
// to: "Please wait for 2 hours before continuing with painting."
|
||||||
function createStringFromTemplate(template, variables) {
|
function createStringFromTemplate(template, variables) {
|
||||||
|
if(Object.prototype.toString.call(template) !== '[object String]') {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
if(variables.fallback && !template.match(new RegExp("\{.+\}"))) {
|
if(variables.fallback && !template.match(new RegExp("\{.+\}"))) {
|
||||||
template = variables.fallback;
|
template = variables.fallback;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user