When using the "Language autocomplete (Tags style)" widget and selecting a language that contains a comma (i.e. "Chinese, Traditional" or "Portuguese, Brazil"), the node can't be saved but throws an error "An unexpected language is entered."

Probably the part after the comma is interpreted as its own language, and then not recognized as one of the accepted languages.

I don't know whether this can be fixed by the module itself, as widgets and languages are part of core. If not, I'd suggest to drop this widget type completely.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

maenjuel created an issue. See original summary.

johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.5
Status: Active » Closed (cannot reproduce)

I tested this in Drupal 9 with module version 8x-1.5+dev. It works fine.

johnv’s picture

Status: Closed (cannot reproduce) » Active

Reset to 'Active'.
After applying #3192811: Autocomplete controller permission and using a basic user, the error appears.
Apparently, it has something to do with the permissions, together with #3195763: Support 'Disable language' module.

johnv’s picture

It works when the complex language is surrounded by quotes, like this: Bulgarian, Burmese, English, "Chinese, Simplified" .
In display, the same result appears.

johnv’s picture

Version: 8.x-1.5 » 8.x-1.x-dev

KuzyaWkk made their first commit to this issue’s fork.

kuzyawkk’s picture

Status: Active » Needs review

Hi, in comment !4 johnv described that the widget would work correctly if you wrap the language in quotes, then everything will work correctly. I added JavaScript, which automatically adds quotes when you select a language with autocomplete.
Before: Chinese, Simplified
After: "Chinese, Simplified"

cedricl’s picture

Can confirm the changes in the MR fix the issue.

  • johnv committed e432f430 on 8.x-1.x
    Issue #3127877 by kuzyawkk: 'Language autocomplete (Tags style)' widget...
johnv’s picture

Version: 8.x-1.x-dev » 8.x-1.9
Status: Needs review » Fixed

Thanks, committed.
I added some code when the field is a multi-value field.

  • johnv committed 3ec77355 on 8.x-1.x
    Issue #3127877: phpcs corrections
    

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.