User language is missing in 3.14 create user form?

Hello,
I am using version 3.14.2 of the CHT.
I just realized that the create user form no longer has a language selection option and the language field is missing from the couchdb user json doc.
Now I’m wondering how to get the current user’s language as an input parameter in a form?
Thanks

language field is missing from the couchdb user json doc

The language for the user has become a session-level configuration in the CHT that is no longer stored in the user’s doc. (Instead, whatever language the user selects when logging in will be the language used for that session.)

That being said, the user’s currently selected language for the session is available in the form data at inputs/user/language

Thanks @jkuester for your reply
I don’t really think my version works that way.
I created a user and this is what it looks like in the database:

{
  "_id": "org.couchdb.user:chw",
  "_rev": "1-0cab7f3e72de9847a5342927dc4899ae",
  "name": "chw",
  "type": "user-settings",
  "roles": [
    "chw_uhc"
  ],
  "facility_id": "29f2d976-342c-4330-9fed-64a4f82417b9",
  "contact_id": "4403d492-db43-4505-8870-8c096beb6601"
}

And this is the input section of my form:

When I display the language value, I get nothing
But when I add language field to user doc like below:

{
  "_id": "org.couchdb.user:chw",
  "_rev": "1-0cab7f3e72de9847a5342927dc4899ae",
  "name": "chw",
  "type": "user-settings",
  "roles": [
    "chw_uhc"
  ],
  "facility_id": "29f2d976-342c-4330-9fed-64a4f82417b9",
  "contact_id": "4403d492-db43-4505-8870-8c096beb6601",
   "language": "fr"
}

That works well, I can see the value of my language variable which reflects the current user’s language!
What should we do in the case the user doc doesn’t have the language field?

In 3.14.2 at inputs/user/language the value is always an empty string, however with the same form in 3.15 I get the user language, I’m pretty sur that in 3.13 this variable was not empty with the sames forms

2 Likes

I’ve found that in 3.14 version the LanguageCookieService is not injected here but injected in master
3.14

 if (userRoot.length) {
          this.enketoTranslationService.bindJsonToXml(userRoot, user);
        }

but actually we have

    if (userRoot.length) {
          const userObject = { ...user, language };
          this.enketoTranslationService.bindJsonToXml(userRoot, userObject);
        }

master

1 Like

Ah, my mistake! @bamatic is correct. This functionality works in the later versions of CHT core, but is broken in 3.14.x. I did some more digging and confirmed that cht-core 3.12 accidentally broke this in this issue. And it was not fixed until cht-core 3.15.0 with this issue.

Unfortunatly, I do not think there is any way to get the user’s language in the form in 3.14.x.

1 Like

So upgrading is the solution for that.
cool, many thanks to you @bamatic & @jkuester

1 Like