XLSForm / pyxform

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

For forms with two or more languages (incl. default/unnamed), use itext for all translatable columns #584

Open lindsay-stevens opened 2 years ago

lindsay-stevens commented 2 years ago

In #571 it was found that sometimes the behaviour (noted as TODO's in test_translations.py, also see this thread) for the default/unnamed language can be surprising when more than one language is present in a form.

For example the following XLSForm results in an XForm with label ref="jr:itext..." in the body, an itext translation for the eng label "hi there" but the unnamed label "hello" is not in the XForm at all (neither body or itext). The same can happen for hints.

| settings |                  |
|          | default_language |
|          | eng              |
| survey |      |      |       |            |            |
|        | type | name | label | label::eng | hint       |
|        | note | n1   | hello | hi there   | salutation |

See the test_translations.py file for other examples. The XForms spec allows both a body label and ref at the same time, e.g. <label ref="jr:itext('mykey')">a default value</label>. However it may be more straightforward to consider forms with 2 or more languages to be in "itext-only" mode, especially since translatable columns (aka text value forms) other than label/hint always go into itext.

As noted by @lognaturel, some pyxform users (non-Collect/Enketo) may expect / require single-language forms to still use the body for label / hint so this behaviour should be retained.

Another possible regression could be if users intended the unnamed language label or hint to be used as the default across multiple languages. This seems somewhat unlikely (perhaps more reasonable for images/media), but the workaround would be to copy the label or hint text into columns for those other languages.