Drupal does not allow W3C compliant language codes where you target a numeric region

Created on 19 June 2013, almost 12 years ago
Updated 4 May 2025, 5 days ago

I have a need to create a Spanish site targeting a Latin American audience. It is my understanding that valid language code would be es-419 for this, but Drupal doesn't allow me to create this, instead it throws an error message:

Notice: Undefined index: langcode in language_admin_edit_form_validate() (line 365 of core/modules/language/language.admin.inc).
 may only contain characters a-z, underscores, or hyphens.

The W3C page that is linked on the very same page where you can define a custom language even lists this language code as one of it's examples:
"es-419 Spanish as used in Latin America"
http://www.w3.org/International/articles/language-tags/

Other use cases for this is if you wish to create an English language site targeting a Middle Eastern audience, where (I think) it would make sense to use en-145 as language code:

http://schneegans.de/lv/?tags=en-145&format=text

Beta phase evaluation

<!--Uncomment the relevant rows for the issue. -->
🐛 Bug report
Status

Fixed

Version

8.0 ⚰️

Component

language system

Created by

🇫🇮Finland badrange

Live updates comments and jobs are added and updated live.
  • D8MI

    (Drupal 8 Multilingual Initiative) is the tag used by the multilingual initiative to mark core issues (and some contributed module issues). For versions other than Drupal 8, use the i18n (Internationalization) tag on issues which involve or affect multilingual / multinational support. That is preferred over Translation.

  • Needs backport to D6

    After being applied to the 7.x branch, it should be considered for backport to the 6.x branch. Note: This tag should generally remain even after the backport has been written, approved, and committed.

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.

Production build 0.71.5 2024