-
Notifications
You must be signed in to change notification settings - Fork 82
Fix #268: create empty nodes for missing translations #270
Conversation
i have not tested or verified this, but the changes look simple enough. |
var pushChildren = function (arr, ext, frm, txn, pre) { | ||
var pre = (pre !== undefined) ? pre : ""; | ||
|
||
// #268: skip unless ext contains at least one non-empty value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We test whether e.g. English (first lang) has a value given, while other added languages are empty. In that case, we'll want empty nodes. Only if nothing is given, we can skip creating nodes.
_noWhitespace: true, | ||
children: getTranslation(ext, txn, prefix = pre) | ||
}); | ||
} else if ((ext !== undefined) && contains_non_empty_value && _.isEmpty(ext[txn._languageCode])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If any other language contains a non empty value (contains_non_empty_value
) but this translation is empty (isEmpty...
), then push an empty node (children: [""]
).
@@ -262,7 +293,7 @@ var dataNS = odkmaker.namespace.load('odkmaker.data'); | |||
{ | |||
|
|||
// The translation for the main control object obj | |||
var schoolyard = [{ | |||
var tx = [{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've renamed this variable because the metaphor of pushing children across a schoolyard has no explanatory value. The additional function docs now clarify what this function does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
This patch fixes a bug that was introduced through added support for extras (short label, guidance hint, image labels etc).
This patch has been split out from #266 as requested.