Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Sync Form language with UI language (if match found) #95

Closed
enketo-issue-mover opened this issue Sep 10, 2018 · 27 comments
Closed

Sync Form language with UI language (if match found) #95

enketo-issue-mover opened this issue Sep 10, 2018 · 27 comments
Assignees
Milestone

Comments

@enketo-issue-mover
Copy link

From @MartijnR on June 23, 2016 22:13

Will require recommended language name with iso code such as English (en), Arabic (ar) as agreed in ODK Dev forum: https://groups.google.com/forum/#!searchin/opendatakit-developers/language$20names$20proposal%7Csort:relevance/opendatakit-developers/ZLDJanOCudE/T7yTrDMYVAsJ

See "Tip: Prepare for the Future" in this post: http://blog.enketo.org/advanced-language/

Algorithm:

Copied from original issue: kobotoolbox#526

@enketo-issue-mover
Copy link
Author

From @smusula on July 13, 2016 11:26

How is this expected to work?

Will it possible for someone to have a url like https://enketo.ona.io/::YYGk?language=Amharic? - where Amharic is one of the languages defined in the XLSForm.

@enketo-issue-mover
Copy link
Author

From @MartijnR on July 13, 2016 15:10

It's not determined yet how this will work. Your suggestion is an option but it would use the official 2-character language code (IANA) instead. I think we should at least include:

  1. If browser locale is available as form language load that form language as default (ignoring any defined XForm default?).
    2. If user switches form language, the UI language should also be switched if that language is available.

@enketo-issue-mover
Copy link
Author

From @smusula on July 26, 2016 9:29

Thanks for the feedback

@enketo-issue-mover
Copy link
Author

From @MartijnR on October 11, 2016 18:49

point 1 could be taken care of by e.g kobotoolbox@57dd427 (note this is not in master and this branch will not be merged in master)

@enketo-issue-mover
Copy link
Author

From @MartijnR on March 27, 2017 19:58

This issue has been reduced to only solve point 1.

Though OC would need point 2 as well. Maybe as an online-only feature, or a limited set of languages that can be set in config.json since most small implementations may not need all languages. Problem is that lots of strings are added in jade/pug.

@MartijnR
Copy link

MartijnR commented Jun 4, 2019

I think this can be done.

  • implement first item in enketo/enketo-express
  • add data-i18n attributes for UI elements added in enketo-core (esp widget buttons)
  • use data-i18n attribute for UI texts added in pug in enketo-express
  • when user switches, add logic to load additional translation file (would only work online)
  • do a DOM text replacement for all elements with data-i18n attributes

MartijnR added a commit to enketo/enketo-core that referenced this issue Jun 5, 2019
@MartijnR
Copy link

The goal is to always sync UI and form whenever both exist

@pbowen-oc
Copy link

If a form is only defined to use one language and that language/locale is not listed on the Choices or Survey sheets, will the form still be able to have a default language defined on the Settings sheet and have that be used to synchronize the form and UI text?

@MartijnR
Copy link

No, I believe not. That would be form definition error if the default language doesn't actually exist in the form.

@pbowen-oc
Copy link

So if I wanted to only offer my form in French and ensure that was used as the default language, I would only define one label column and call it "label::French (fr)" and set French (fr) as my form's default language? Is that correct?

@MartijnR
Copy link

estimate hours

@MartijnR
Copy link

12-16 hrs

@MartijnR
Copy link

MartijnR commented Apr 9, 2020

This is done. It was a present from me. (will be in next merge from enketo/enketo-express)

@pbowen-oc
Copy link

Thanks! :)

@MartijnR
Copy link

@pbowen-oc
Copy link

pbowen-oc commented May 19, 2020

@MartijnR - I understand that my text columns would need to be defined like:
"label::English (en)"
"hint::French (fr)"

Would I also specify the Default Language in this format: i.e., "English (en)"?

@MartijnR
Copy link

MartijnR commented May 19, 2020 via email

@pbowen-oc
Copy link

@MartijnR - Do we need to do anything to enable language syncing based on browser language settings?

I created a form with "French (fr)", "English (en)", and "German (de)" defined in that order for all content columns. Default language is defined in the form as "German (de)". When I open the form, the following language list is visible in the network calls:
"languageMap": {
"German (de)": "de",
"French (fr)": "fr",
"English (en)": "en"
}

Since my Windows browsers (tested in Chrome, Edge, Firefox) are set to English (United States), I expected that opening the form would default the language selector to English. However, in most cases, I'm getting German. I'm getting the same results with my iPhone/iPad as well.

v2.5.6.oc-11
/preview/i/ mode: form loads in English (as expected)
all other modes: form loads in German

current master:
preview and all other modes: form loads in German

Other modes tested: /view/fs/i/, /single/fs/c/i/, /edit/fs/c/i/

Any idea what I am doing wrong or what we need to change?

@MartijnR
Copy link

I believe not defining a default language would make it do what you want. The feature has evolved a bit lately.

See this sheet: https://docs.google.com/spreadsheets/d/1CigMLAQewcXi-OJJHi_JQQ-fJXOam99livM0oYrtbkk/edit#gid=1504432290

@pbowen-oc
Copy link

pbowen-oc commented May 13, 2021

@MartijnR - I am still seeing an issue with this on the latest master branch after removing the Default Language configuration.

On our Preview server, it seems to be working as exactly as expected based on our discussion. French is the first language in my form, but it loads for me in English and the form language and UI language are both English and change together if I select French or German.

On our primary editing server, it loads with French selected. Additionally, while the language selector controls the form language as expected, it has no effect on the UI language. So, the form loads with my French text but English buttons.

Test Form:
language test.xml.txt

Preview mode working as expected (after selecting French manually):
Screenshot 2021-05-12 232144

Edit mode not synced and not loading in bowser language (with French incorrectly selected upon load or if I later manually select French):
Screenshot 2021-05-12 232207

Edit:
After a little further testing on our primary editing server, I see that the UI is loading in the browser language here but the issue is that it is not synced with the language selector. Here is another test with my browser set to German when I load the form:

Screenshot 2021-05-13 000448

@MartijnR
Copy link

MartijnR commented May 13, 2021

  • check regular fieldsubmission view /oc/api/v1/survey/collect
  • check regular enketo/enketo-express view /api/v2/survey
  • check instance/edit fieldsubmission view /oc/api/v1/instance/edit

@pbowen-oc
Copy link

I was blocked from testing this fully before by an unrelated bug, but I just verified that /preview/i/ on our primary editing server is fully synced as expected. So, it does appear to be only the non-preview modes that don't have the language synced.
Screenshot 2021-05-19 203812

@MartijnR
Copy link

MartijnR commented May 25, 2021

Possibly related to this https://github.com/OpenClinica/enketo-express-oc/blob/master/public/js/src/enketo-webform-fieldsubmission.js#L163 (happened to notice when working on other issue)

If so, it might get fixed by OpenClinica/enketo-oc#156

@MartijnR
Copy link

MartijnR commented Dec 15, 2021

EE-OC: http://localhost:8005/single/fs/i/B2QloRRY?ecid=1 - UI lang is correct, form language is incorrect first language (french)
EE: http://localhost:8005/B2QloRRY - works correctly

@pbowen-oc
Copy link

pbowen-oc commented Feb 15, 2022

@MartijnR - I have a question and an issue to report. I am using version 2.8.0.oc-9.

  1. Suppose my browser is set to use Chinese and that English is the second language in order of preference. Suppose my form definition doesn't have a default language set and that Chinese is not include in the form, but English is included in the form (along with other languages). What language am I expected to get when I open the form?

I had expected to get English since it is my #2 browser language and it is a language used in the form. However, I am getting the form in the first language as defined in the XForm. Is Enketo expected to only utilize the default language set in the browser and if that is not in the form it would just fall back to the first XForm language?

  1. When opening a multi-language form (such as this one: language test2.xml.txt ) it opens with the form content and UI synced as expected. However, when I change to a different language using the language selector, the form content changes as expected but the UI remains on the old language. If I change the language selector again, the form content changes as expected, but the UI changes to the previous selection. In other words, after initial load, the UI is always out of sync with the form content/selector (specifically, it is on the previous language selection).

Form first opened (languages synced):
Screenshot 2022-02-14 234019

Language changed (UI has not changed):
Screenshot 2022-02-14 234037

Language changed (UI has changed, but to the previous selection):
Screenshot 2022-02-14 234105

@MartijnR
Copy link

MartijnR commented Feb 18, 2022

@pbowen-oc
Copy link

This is working as expected and simply needs to be documented on our end. The form will only have knowledge of the primary language in the browser and not and other preferred languages in the browser settings.

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

No branches or pull requests

3 participants