https://api.drupal.org/api/drupal/includes!locale.inc/function/locale_ad...

See also: https://drupal.org/node/1679096

locale_add_language('en-CA', 'English (Canada)', 'English (Canada)', LANGUAGE_LTR, '', '', true, true);

Expected result: Add a new language, and set it as default, with an empty prefix
Actual result: Adds a new language, but, since $prefix is tested using empty() instead of === NULL, the new language gets $langcode set as its prefix.

1. local_add_language()'s signature should be changed to have $prefix = NULL
2. $prefix should only be set to $langcode when it is literally NULL

Request for comments: what are your foreseeable good/bad consequences with this suggested tweak?

Comments

mac_weber’s picture

@starlocke the language prefix is used for example in the URL for detecting a language.
English provided by Drupal does not have a prefix by default. Which I think is not a good thing.
You cannot have unique URL's for different languages if don't have the prefix.

Maybe there are other uses for the language prefix which I'm not aware.
I don't see any benefit on allowing to save empty or NULL prefixes.

I'm leaving the issue open to see if someone comes with different opinions.

mac_weber’s picture

Issue summary: View changes

Dropped pointless comment about /admin/ pages.

Status: Active » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.