Needs work
Project:
Features
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
11 Jul 2012 at 09:31 UTC
Updated:
6 Jun 2013 at 17:35 UTC
Jump to comment: Most recent file
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?
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1679096-unable-to-create-languages-with-empty-prefix.patch | 580 bytes | luisortizramos |
Comments
Comment #1
mpotter commentedTrouble 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.
Comment #2
luisortizramos commentedWe 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.
Comment #3
starlocke commentedExpected 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$langcodeset as its prefix.1.
local_add_language()'s signature should be changed to have$prefix = NULL2.
$prefixshould only be set to$langcodewhen it is literallyNULLComment #4
starlocke commentedSee also: https://drupal.org/node/2013917