How to set the default language (using pyxform to convert xlsx to xml)

Dear Forum,

I have been testing the output of pyxform, trying to understanding how to "impose" the language I want to use as default. I had the following issue:

  • survey and choices sheet with 2 languages (e.g. Portuguese (pt) and Español (es) ),
  • default_language set to pt,
  • portuguese columns coming first in all sheets.
  • still, xml has the Espanol label first and the phone will take it as default language

(of course you can change it from the Menu, but we wanted to have it automatic)

I realized that pyxform chooses as default language the one whose label come first, i.e., if I have a "calculate" type question with a label in Spanish (second language in my survey), but not in Portuguese (first language in the survey) pyxform will set Spanish as default.

My solution for this is to add a "calculate" variable at the beginning, and put a label only in the column corresponding to the default language that I want.

Did anybody experienced a similar issue or observed a similar behavior? Is there a better solution?

@Ukang_a_Dickson I think this might be a bug in pyxform?

We can look into this. I won't mind having an example XLSForm from Alfonso. Has an issue been created?

1 Like

Have you tried setting default_language to Portuguese (pt) rather than pt? The language code is a convention that can be used by clients but pyxform has no knowledge of it. The value in default_language should match the full language description in the column header.

If that’s still not working, I agree a sample form would help!

Thank you for all answers.

I tried the suggestion of Hélène, but this also did not work.

I have created few sample surveys. In the one attached, converting with pyxform I get a xml form in which the Spanish version comes first [wrong]

I tried two things now:
(1) remove the label in J4 and putting a label in G4 --> now the resulting XML form starts with Portuguese [correct]
(2) Just adding a label in G4 --> this results in strange behavior, sometimes the resulting form still has Spanish default [wrong]
(3) Create a new form with a new name, with both label in G4 and J4 --> Portuguese xml form. [correct]

debug.xlsx (32.4 KB)

I'm so sorry you never got a response on this, @alfonso. It has come up again as we are working on some XLSForm improvements. Hopefully you got things working as you expect.

I was not able to reproduce the issue you identified. When I convert your attached form, the resulting XML has <translation default="true()" lang="Portuguese (pt)"> which is what I would expect. Note that the form is a bit unusual because calculates don't display labels.

I have verified that ODK Collect does show Portuguese as the default. The order of the translation blocks in the XML should not matter. If you're still having problems, it would be good to know what version of Collect you are using.

Dear Hélène,

thank you for getting back to this topic after such a long time! Mean while I figured out it must be an issue with the pyxform converter.

When I convert the xlsx, the xml does not have the default="true()" in the translation tag. (even if the xlsx has a default specified). And the order of translations changes every time I convert the xlsx.

My workaround was, so far, keeping converting until I got the "desired" language first :slight_smile: But I will try adding manually the default="true()".

Thank you!

!!! What converter are you using? What version? (e.g. do you use http://opendatakit.org/xlsform/, XLSForm Offline...?)

2 posts were split to a new topic: Setting a default language in Enketo