Plugin fails to translate when using regional variants in source language (e.g., zh-hans)

Created on 20 October 2025, 6 days ago

Problem/Motivation

Currently, for source language codes, the module expects ISO 3166-1 alpha-2 codes without regional variants (e.g., zh instead of zh-hans). However, Drupal core often provides language codes with regional variants such as zh-hans or pt-br.

When creating content in Chinese (zh-hans in Drupal) and attempting to translate it into another language, the plugin fails to perform the translation.

Steps to reproduce

  1. Create a page in Chinese (zh-hans).
  2. Attempt to translate the page into another language.

Proposed resolution

The source language code should be normalized before being used for translation.
Specifically, it should be passed through:
LanguageCode::removeRegionalVariant()

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇬🇪Georgia IliaNoz

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

No activities found.

Production build 0.71.5 2024