This task ties together the work that was in TBC and T305539, and so it depends on them being done first.
To make language code inference work, an action is needed that is probably triggered by the selected value of the LanguageLookup changing.
This action should probably do the following things:
- set the language store field to whatever was selected in the LanguageLookup
- set the languageCodePropertyValue store field to undefined
- use the repository/service created in T305539 to retrieve the language code property data from the API
- if a language code was returned by the api, then validate it
- set the languageCodePropertyValue store field accordingly, see the table below
Finally, the App components need to be told how to react to the languageCodePropertyValue, see the below:
Conceptual state | language store field | languageCodePropertyValue store field | app state |
---|---|---|---|
No language Item selected (initial state) | falsy | undefined | No spelling variant lookup, no warning message |
Loading language code request | 'Q123' | undefined | No spelling variant lookup, no warning message (maybe loading indicator shown?) |
No language code | 'Q123' | null | Yes spelling variant lookup, no warning message. |
Invalid language code (meaning the retrieved code is not in the list of allowed codes) | 'Q123' | false | Yes spelling variant lookup, yes warning message. |
Valid language code | 'Q123' | 'en-ca' | No spelling variant lookup, no warning message. |