Missing default language warning

As noted here - https://github.com/XLSForm/pyxform/pull/365 we need to design the UX before we implement the feature, so here is what I am going to target.

User experience
Warnings will appear in the command line for each question missing a translation with the text
Edited 4/4/20
"Missing translation for content on question!
Question name: {question_name}
Content type missing translation: {content_type}
Missing translation for: {language} "

Then, ONLY if default language is not set
"Default language not set. Please consider setting a default_language in your settings tab to insure questions and options appear as expected."

Technical notes
I want to detect in the code where a - is being set on a field. If I can confirm this field will be displayed with that - I will add the warning there. (original form available here Adding media column results in blank screen )

Originally, I used a warnings list as an attribute to the class Survey and just adding warnings as appropriate. Let me know if anyone has a better idea.

Please LMK if the above makes sense or if it can be improved.

This would've been a good question when I first started working on issue 157 but the spec says

Multi-lingual content for labels, and hints is supported.

So basically, anything that might need this warning should be a label or a hint, correct? does tht question make sense?

It looks to me like media and string labels are the only kinds worth worrying about in translations, right? meaning that label:: media:: and hint:: are the three scenarios I need tests for? (testing the scenarios that languages are provided for one and not the other, with no default lang in settings)

@Ukang_a_Dickson just a quick bump in case you have thoughts on this, it was @LN 's idea to discuss this a bit more. Im going to start in on implementation but Ill make somethign thats pretty easy to change if we need to.

Updated text for warnings, I think these make more sense

                        "Missing translation for content on question! " + 
                        "language lacking translation: " + lang + 
                        "\n name: " + question_name +
                        "\n content missing translation: " + content_type
                    ) if lang != 'default' else (
                        "A `default_language` has not been set on this form.\n" +
                        "Set this in the settings tab and columns with no set " +
                        "language will default to the language specified there."

Thanks for pushing on with this, @KeynesYouDigIt.

There could possibly be quite a few of these warnings on a form definition so I think it's important to make sure that the warning message is compact. See also @Ukang_a_Dickson's code review note. I think it's that note which made you add the content type. I don't think that's necessary if the question name is clear. A more compact version of what you're proposing could be

Translation for language '{language}' missing for question '{question_name}'

This form is an example you may want to try with the change you are proposing. It's a case where several of the French translations are missing because they are on hold waiting for an explicit ask for them. I think it's not uncommon to only have a partial translation available and still need to try out the form. We want to make sure translation warnings don't drown everything else out.

I don't think default_language does what you think. It just determines which language is selected by the client at form launch if the user hasn't set a specific language. Any warning about default_language should occur exactly once.

Let's take a step back and review the original issue. That issue is about the choice of columns and settings, not about missing languages on individual questions. The ideal would be to identify all localizable columns in the form and all languages in the form and make sure that every localizable column exists in every language.

I believe the localizable column types are label, hint, media::image, media::video, media::audio but it would be good to double-check that in the code.

For example, if a form has columns label, hint, media::image, that's great, no problem. Similarly, if it has label::French (fr), hint::French (fr), media::image::French (fr), that's also great. pyxform takes care of making French (fr) the default language and everything works as expected. The problem is if a form has columns label::French (fr), hint::French (fr) and media::image. Now there are two languages in play: default and French (fr). However, French (fr) is missing the media::image column and the default language is missing the label and hint columns.

The challenge is to come up with a warning that would help a user. It might be something like "Translations are incomplete: languages French (fr) and default are missing columns. See https://xlsform.org/ for help."

1 Like

Wonderful answer thx. In between the wedding/COVID/general crazyness right now, im not sure when I will be able to jump on this, but I am hoping soon!

I am going to go with

as the warning message, let me know if that sounds good.

I am trying to think through this specific case though-

since media::image doesnt have a language specified, the warning would simply be

Translation for language 'French (fr)' missing for question 'my media question'`

Is that correct and helpful to a user? or might that confuse users that dont realize media questions are localizeable?

also, is there a succinct list of localizeable questions? The spec doesnt appear comprehensive

But I will do some digging in the code and add it there if I find something

Ah one more question - what should we do if we encounter a scenario like

label, label::French (fr), label, hint::French (fr) and media::image::French (fr).

Unaddressed, This would output something like

Translation for language 'default' missing for question 'my media question'`

Would this be a case where something like

please set default language

might be good? what should we do if we hit that case? Perhaps its rare enough that the first message I posted is OK? or should we not even warn then?
@LN @Ukang_a_Dickson

Revisiting @Ukang_a_Dickson 's code review comment () it seems like column name is also relevant. I am going to try and build a warning like

Translation for language '{language}' missing for column '{column_name}' on question '{question_name}'

Ironically, getting the column name is the (kind of) easy part. figuring out exactly what question I an working with in the translations has been fairly hard.

Judging by what's written above, the main warning is for a missing column or alternatively a missing default_language parameter on the settings sheet (as either would solve the problem). These are aspects which relate to the structure of the entire form and not individual questions (generally all questions have exactly the same columns even if some are empty) so you wouldn't need to find the relevant question name for this error or display a question name in the error message.

Missing translations for individual questions would be a completely separate idea and while useful to know about, would not be a technical error in any way, more likely an incomplete form. It seems that is not the primary focus of this warning.

Ideally the error message would be able to give the name of the missing column, in your example, possibly something like the below.

"Missing localization (media::image) or default_language setting"

Of course it's possible that in one form there could be multiple missing columns. I am not sure if in that case you display multiple errors or you can list the column names in one error. I suspect the second option would be better but the first option would be easier to code.


Thanks for that helpful response, @noel_cartong. I think I confused things by bringing up a more compact wording for the case where a question is missing a translation. You're absolutely correct, the most important goal would be to identify missing columns.

This is the part to really pay attention to:

In the mean time, I've realized guidance hints, constraint messages and required messages are also localized but weren't included in my list above. So it's definitely important to identify all of those as a first step.

I agree that would be helpful. Perhaps it can be layered on.

1 Like

I've had trouble building a real authoritative list of localize-able column types. The process to build the translations seems to interact with any SurveyElement. That said I think I have a solid start on where I want to go with this. might be able to get a full PR up this weekend, but if its of any interest theres a current one open that just prints a bare-bones version of the warning im thinking about. Also includes a test case.https://github.com/XLSForm/pyxform/pull/482

Dang you are right! not sure why that didn't click earlier. That makes things much easier.

I will have a PR up soon and should be able to tackle further functionality questions there.

No worries, you're contribution to the tool is much appreciated. Not knowing which language columns to include is a common mistake for people learning to create forms so this check will help a lot.