Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't generate itext block if only one language is defined #285

Closed
lognaturel opened this issue Apr 10, 2019 · 6 comments · Fixed by #376
Closed

Don't generate itext block if only one language is defined #285

lognaturel opened this issue Apr 10, 2019 · 6 comments · Fixed by #376

Comments

@lognaturel
Copy link
Contributor

lognaturel commented Apr 10, 2019

The itext block can include translations for form elements (see spec). pyxform always adds this level of indirection for cascading selects, even if the XLSForm only defines labels/hints for a single language. This isn't a big deal for small secondary instances but can make the XML much bigger for large ones.

Related to #32 and might be good to address while in the same brain space.

@lognaturel
Copy link
Contributor Author

See nigeria_wards_internal.xml.txt and nigeria_wards_internal_simplified.xml.txt for what I'm talking about. File size goes from 4.6mb to 3mb.

@nribeka
Copy link
Contributor

nribeka commented Sep 24, 2019

Checking this one along while waiting for PR review.

@lognaturel
Copy link
Contributor Author

@nribeka This is a really good one to look into. Please ask if you have any questions about the problem or intended behavior.

@nribeka
Copy link
Contributor

nribeka commented Sep 24, 2019

@lognaturel is there a place where i can get the xls for the form?

From your description and looking at the xml, the idea is to not use the translation field when there's only one language, right? It should inline it instead of separating it. This is only true when the survey have one language only, right?

@lognaturel
Copy link
Contributor Author

lognaturel commented Sep 25, 2019

the idea is to not use the translation field when there's only one language, right? It should inline it instead of separating it. This is only true when the survey have one language only, right?

Yes, exactly.

Simple example: XLSForm, XForm

Note that the static choice list uses literal label text which is what is expected. When I force a dynamic choice list by using a choice filter is where the problem occurs.

What we'd like:

<instance id="choices">
	<root>
		<item>
			<label>Choice 1</label>
			<value>choice 1</value>
		</item>
		<item>
			<label>Choice 2</label>
			<value>choice 2</value>
		</item>
		<item>
			<label>Choice 3</label>
			<value>choice 3</value>
		</item>
		<item>
			<label>Choice 4</label>
			<value>choice 4</value>
		</item>
		<item>
			<label>Choice 5</label>
			<value>choice 5</value>
		</item>
		<item>
			<label>Choice 6</label>
			<value>choice 6</value>
		</item>
	</root>
</instance>

The itemset declaration will also need to change:

<itemset nodeset="instance('choices')/root/item[name != '']">
   <value ref="name"/>
   <label ref="label"/>
</itemset>

@nribeka
Copy link
Contributor

nribeka commented Sep 26, 2019

@lognaturel,

Another approach would be:

  • Add new field in the survey object when creating survey object from the json.
  • Use that field (in favor of checking the multi_language all the time) when creating each section.

Thoughts?

The above draft PR obviously break existing tests that have reference to the field. I'm gonna change the expected output xml files if that's ok?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants