My feature should provide three languages, the default is Estonian and it should not have a prefix:

  $languages['et'] = array(
    'language' => 'et',
    'name' => 'Estonian',
    'native' => 'Eesti',
    'direction' => '0',
    'enabled' => '1',
    'plurals' => '0',
    'formula' => '',
    'domain' => '',
    'prefix' => '',
    'weight' => '-10',
  );

The problem should be in that _features_language_save calls locale_add_language which adds the prefix in any case:

function locale_add_language($langcode, $name = NULL, $native = NULL, $direction = LANGUAGE_LTR, $domain = '', $prefix = '', $enabled = TRUE, $default = FALSE) {
  // Default prefix on language code.
  if (empty($prefix)) {
    $prefix = $langcode;
  }

Im wondering if the correct fix would be to replace the empty "prefix" attribute value in the language array with TRUE which would pass the empty() check? or to replace the locale_add_language with custom implementation?

Comments

mpotter’s picture

Status: Active » Closed (won't fix)

Trouble is that using something like TRUE will cause the wrong value to be saved to the database and put into the system variable. I'm afraid you need to post this over in the Locale section for Drupal core to get this fixed. They need to modify the locale_add_language to support sending a blank prefix there.

luisortizramos’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new580 bytes

We know that the problem is with the Core, they will solve it, but while it happens I've created a little patch to workaround it.

starlocke’s picture

Status: Needs review » Needs work
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

starlocke’s picture