683: select or_other label is "-" in multilanguage form not "Other" #687
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Prior to using secondary instances for all selects, the default label for the or_other shortcut was "Other" in all languages. Despite the various warnings, users wanted the old behaviour to be retained. The exception is that if a user has defined an "other" choice for the or_other choices, then any blank translations labels ("-") will not be replaced with "Other".
Closes #683
Why is this the best possible solution? Were any other approaches considered?
I tried to find a way to offload the logic to survey.py because that is where translations and missing defaults are done, but it became quite messy. Basically the OR_OTHER choice had an extra attribute
"_or_other": True
and this was used to trigger special processing when setting up translations and overriding the default missing translation-
.This PR is similar to #684. It seems like builder.py is the best place to add this code because it's where the
or_other
input item is injected, and where the regularor_other
choice is added. Differences from #648:_add_other_option_to_multiple_choice_question
, the choice name should matchother
exactly instead ofother
being anywhere in the choice name (e.g.smothers
)._get_or_other_choice
since it might not be translated._get_or_other_choice
:map
with set/dict comprehensionsother
choice since it doesn't exist in the form. This is still true with pyxform v2. Maybe should be discussed further for a separate PR.or_other
related tests are put into a new TestCase class, to help visually separate them from others. This is preferable to the proposed use ofregion
comments becauseregion
doesn't seem to work for Intellij (which I use), and grouping tests by TestCase class (which can be folded in Intellij) ortest_...py
module file is a more standard way to organise tests.What are the regression risks?
The only one that comes to mind is that as mentioned above, if a user has defined an "other" choice for the or_other choices, then any blank translations labels ("-") will not be replaced with "Other".
Does this change require updates to documentation? If so, please file an issue here and include the link below.
No
Before submitting this PR, please make sure you have:
tests
nosetests
and verified all tests passblack pyxform tests
to format code