XLSForm / pyxform

A Python package to create XForms for ODK Collect.
BSD 2-Clause "Simplified" License
75 stars 133 forks source link

#653 Detection of multilanguage choices only works if first choice list is multilanguage #666

Closed lindsay-stevens closed 6 months ago

lindsay-stevens commented 6 months ago

Closes #653

Why is this the best possible solution? Were any other approaches considered?

There are 2 main problem areas addressed: the translation warning, and the detection of translations for triggering multi-language (itext) output behaviour,

This changes the missing translations check in xls2json to use column headers instead of the first row. To avoid re-iterating the sheet data, the existing dealias function is modified to track and return the headers as well as the sheet data.

This changes multi-language detection by doing so only in the Survey object. For the Question sub-types, Survey sets the relevant info with new fields, so that the Questions don't need to re-check. For choices, the detection is per itemset (it could have looked across all itemsets but then untranslated itemsets would've had to be mangled into translations).

What are the regression risks?

Since there are some new fields on the Survey and Question classes, external library users that pass in JSON without these may experience errors or inconsistent behaviour. There is a file json_form_schema.json but it seems to be not consistently updated, and I don't know if it's accurate - there doesn't seem to be a pyxform way to generate it or use it to validate.

Does this change require updates to documentation? If so, please file an issue here and include the link below.

Probably not, it's all internal representation.

Before submitting this PR, please make sure you have:

lognaturel commented 6 months ago

There's a small recommendation and a question about risk inline but I'm going to merge now so we can get it onto staging asap.