Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Fix #268: create empty nodes for missing translations #270

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

florianm
Copy link
Contributor

@florianm florianm commented Jan 10, 2022

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.

@florianm florianm added the bug label Jan 10, 2022
@florianm florianm added this to the 0.4.1 milestone Jan 10, 2022
@florianm florianm requested a review from yanokwa January 10, 2022 23:40
@florianm florianm self-assigned this Jan 10, 2022
@florianm florianm added this to In progress in Roadmap via automation Jan 10, 2022
@issa-tseng
Copy link
Member

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
Copy link
Contributor Author

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])) {
Copy link
Contributor Author

@florianm florianm Jan 14, 2022

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 = [{
Copy link
Contributor Author

@florianm florianm Jan 14, 2022

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.

Roadmap automation moved this from In progress to Reviewer approved Jan 25, 2022
Copy link
Member

@yanokwa yanokwa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@florianm florianm merged commit 1932ffd into getodk:master Jan 25, 2022
Roadmap automation moved this from Reviewer approved to Done Jan 25, 2022
@florianm florianm deleted the 268-empty-nodes branch January 25, 2022 22:42
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
Development

Successfully merging this pull request may close these issues.

Bug: create short label for all translations
3 participants