Commit b9e92441 authored by catch's avatar catch

Issue #965300 by Gábor Hojtsy, xjm: Change LANGUAGE_NONE to...

Issue #965300 by Gábor Hojtsy, xjm: Change LANGUAGE_NONE to LANGUAGE_NOT_SPECIFIED; add LANGUAGE_NOT_APPLICABLE and LANGUAGE_MULTIPLE.
parent e50a4075
......@@ -163,18 +163,47 @@
const DRUPAL_KILOBYTE = 1024;
/**
* System language (only applicable to UI).
* Special system language code (only applicable to UI language).
*
* Refers to the language used in Drupal and module/theme source code.
* Refers to the language used in Drupal and module/theme source code. Drupal
* uses the built-in text for English by default, but if configured to allow
* translation/customization of English, we need to differentiate between the
* built-in language and the English translation.
*/
const LANGUAGE_SYSTEM = 'system';
/**
* The language code used when no language is explicitly assigned.
* The language code used when no language is explicitly assigned (yet).
*
* Defined by ISO639-2 for "Undetermined".
* Should be used when language information is not available or cannot be
* determined. This special language code is useful when we know the data
* might have linguistic information, but we don't know the language.
*
* See http://www.w3.org/International/questions/qa-no-language#undetermined.
*/
const LANGUAGE_NOT_SPECIFIED = 'und';
/**
* The language code used when the marked object has no linguistic content.
*
* Should be used when we explicitly know that the data referred has no
* linguistic content.
*
* See http://www.w3.org/International/questions/qa-no-language#nonlinguistic.
*/
const LANGUAGE_NOT_APPLICABLE = 'zxx';
/**
* The language code used when multiple languages could be applied.
*
* Should be used when individual parts of the data cannot be marked with
* language, but we know there are multiple languages involved. Such as a
* PDF file for an electronic appliance, which has usage manuals in 8
* languages but is uploaded as one file in Drupal.
*
* Defined by ISO639-2 for "Multiple languages".
*/
const LANGUAGE_NONE = 'und';
const LANGUAGE_MULTIPLE = 'mul';
/**
* The type of language used to define the content language.
......@@ -2733,7 +2762,7 @@ function language_load($langcode) {
* The printed name of the language.
*/
function language_name($langcode) {
if ($langcode == LANGUAGE_NONE) {
if ($langcode == LANGUAGE_NOT_SPECIFIED) {
return t('None');
}
......
......@@ -574,7 +574,7 @@ function file_save(stdClass $file) {
// neutral more often than language dependent. Until we have better flexible
// settings.
// @todo See http://drupal.org/node/258785 and followups.
$file->langcode = LANGUAGE_NONE;
$file->langcode = LANGUAGE_NOT_SPECIFIED;
}
// Load the stored entity, if any.
......
......@@ -421,9 +421,9 @@ function language_fallback_get_candidates($type = LANGUAGE_TYPE_CONTENT) {
$fallback_candidates = &drupal_static(__FUNCTION__);
if (!isset($fallback_candidates)) {
// Get languages ordered by weight, add LANGUAGE_NONE as the last one.
// Get languages ordered by weight, add LANGUAGE_NOT_SPECIFIED at the end.
$fallback_candidates = array_keys(language_list());
$fallback_candidates[] = LANGUAGE_NONE;
$fallback_candidates[] = LANGUAGE_NOT_SPECIFIED;
// Let other modules hook in and add/change candidates.
drupal_alter('language_fallback_candidates', $fallback_candidates);
......
......@@ -96,7 +96,7 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
$args = array(
':system' => $cache['system_paths'],
':langcode' => $langcode,
':language_none' => LANGUAGE_NONE,
':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED,
);
// Always get the language-specific alias before the language-neutral
// one. For example 'de' is less than 'und' so the order needs to be
......@@ -105,16 +105,16 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
// the most recently created alias for each source. Subsequent queries
// using fetchField() must use pid DESC to have the same effect.
// For performance reasons, the query builder is not used here.
if ($langcode == LANGUAGE_NONE) {
if ($langcode == LANGUAGE_NOT_SPECIFIED) {
// Prevent PDO from complaining about a token the query doesn't use.
unset($args[':langcode']);
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode = :language_none ORDER BY pid ASC', $args);
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode = :langcode_undetermined ORDER BY pid ASC', $args);
}
elseif ($langcode < LANGUAGE_NONE) {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :language_none) ORDER BY langcode ASC, pid ASC', $args);
elseif ($langcode < LANGUAGE_NOT_SPECIFIED) {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode ASC, pid ASC', $args);
}
else {
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :language_none) ORDER BY langcode DESC, pid ASC', $args);
$result = db_query('SELECT source, alias FROM {url_alias} WHERE source IN (:system) AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid ASC', $args);
}
$cache['map'][$langcode] = $result->fetchAllKeyed();
// Keep a record of paths with no alias to avoid querying twice.
......@@ -136,18 +136,18 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
$args = array(
':source' => $path,
':langcode' => $langcode,
':language_none' => LANGUAGE_NONE,
':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED,
);
// See the queries above.
if ($langcode == LANGUAGE_NONE) {
if ($langcode == LANGUAGE_NOT_SPECIFIED) {
unset($args[':langcode']);
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode = :language_none ORDER BY pid DESC", $args)->fetchField();
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode = :langcode_undetermined ORDER BY pid DESC", $args)->fetchField();
}
elseif ($langcode > LANGUAGE_NONE) {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :language_none) ORDER BY langcode DESC, pid DESC", $args)->fetchField();
elseif ($langcode > LANGUAGE_NOT_SPECIFIED) {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args)->fetchField();
}
else {
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :language_none) ORDER BY langcode ASC, pid DESC", $args)->fetchField();
$alias = db_query("SELECT alias FROM {url_alias} WHERE source = :source AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode ASC, pid DESC", $args)->fetchField();
}
$cache['map'][$langcode][$path] = $alias;
return $alias;
......@@ -162,18 +162,18 @@ function drupal_lookup_path($action, $path = '', $langcode = NULL) {
$args = array(
':alias' => $path,
':langcode' => $langcode,
':language_none' => LANGUAGE_NONE,
':langcode_undetermined' => LANGUAGE_NOT_SPECIFIED,
);
// See the queries above.
if ($langcode == LANGUAGE_NONE) {
if ($langcode == LANGUAGE_NOT_SPECIFIED) {
unset($args[':langcode']);
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :language_none ORDER BY pid DESC", $args);
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode = :langcode_undetermined ORDER BY pid DESC", $args);
}
elseif ($langcode > LANGUAGE_NONE) {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :language_none) ORDER BY langcode DESC, pid DESC", $args);
elseif ($langcode > LANGUAGE_NOT_SPECIFIED) {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode DESC, pid DESC", $args);
}
else {
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :language_none) ORDER BY langcode ASC, pid DESC", $args);
$result = db_query("SELECT source FROM {url_alias} WHERE alias = :alias AND langcode IN (:langcode, :langcode_undetermined) ORDER BY langcode ASC, pid DESC", $args);
}
if ($source = $result->fetchField()) {
$cache['map'][$langcode][$source] = $path;
......@@ -431,7 +431,7 @@ function path_load($conditions) {
* - langcode: (optional) The language code of the alias.
*/
function path_save(&$path) {
$path += array('langcode' => LANGUAGE_NONE);
$path += array('langcode' => LANGUAGE_NOT_SPECIFIED);
// Load the stored alias, if any.
if (!empty($path['pid']) && !isset($path['original'])) {
......
......@@ -282,7 +282,7 @@ EOF;
* (optional) The number of nodes to generate.
*/
function createSampleNodes($count = 5) {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
// Post $count article nodes.
for ($i = 0; $i < $count; $i++) {
$edit = array();
......
......@@ -129,7 +129,7 @@ function book_admin_edit_submit($form, &$form_state) {
// Update the title if changed.
if ($row['title']['#default_value'] != $values['title']) {
$node = node_load($values['nid']);
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$node->title = $values['title'];
$node->book['link_title'] = $values['title'];
$node->revision = 1;
......
......@@ -168,7 +168,7 @@ class BookTestCase extends DrupalWebTestCase {
// Check printer friendly version.
$this->drupalGet('book/export/html/' . $node->nid);
$this->assertText($node->title, t('Printer friendly title found.'));
$this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Printer friendly body found.'));
$this->assertRaw(check_markup($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[LANGUAGE_NOT_SPECIFIED][0]['format']), t('Printer friendly body found.'));
$number++;
}
......@@ -199,7 +199,7 @@ class BookTestCase extends DrupalWebTestCase {
static $number = 0; // Used to ensure that when sorted nodes stay in same order.
$edit = array();
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$edit["title"] = $number . ' - SimpleTest test node ' . $this->randomName(10);
$edit["body[$langcode][0][value]"] = 'SimpleTest test body ' . $this->randomName(32) . ' ' . $this->randomName(32);
$edit['book[bid]'] = $book_nid;
......@@ -237,7 +237,7 @@ class BookTestCase extends DrupalWebTestCase {
// Make sure each part of the book is there.
foreach ($nodes as $node) {
$this->assertText($node->title, t('Node title found in printer friendly version.'));
$this->assertRaw(check_markup($node->body[LANGUAGE_NONE][0]['value'], $node->body[LANGUAGE_NONE][0]['format']), t('Node body found in printer friendly version.'));
$this->assertRaw(check_markup($node->body[LANGUAGE_NOT_SPECIFIED][0]['value'], $node->body[LANGUAGE_NOT_SPECIFIED][0]['format']), t('Node body found in printer friendly version.'));
}
// Make sure we can't export an unsupported format.
......
......@@ -111,7 +111,7 @@ function comment_admin_overview($form, &$form_state, $arg) {
'#type' => 'link',
'#title' => $comment->subject,
'#href' => 'comment/' . $comment->cid,
'#options' => array('attributes' => array('title' => truncate_utf8($comment->comment_body[LANGUAGE_NONE][0]['value'], 128)), 'fragment' => 'comment-' . $comment->cid),
'#options' => array('attributes' => array('title' => truncate_utf8($comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['value'], 128)), 'fragment' => 'comment-' . $comment->cid),
),
),
'author' => theme('username', array('account' => $comment)),
......
......@@ -29,7 +29,7 @@ class Comment extends Entity {
*
* @var string
*/
public $langcode = LANGUAGE_NONE;
public $langcode = LANGUAGE_NOT_SPECIFIED;
/**
* The comment title.
......
......@@ -1843,7 +1843,7 @@ function comment_form($form, &$form_state, $comment) {
// If a content type has multilingual support we set the comment to inherit the
// content language. Otherwise mark the comment as language neutral.
$comment_langcode = $comment->langcode;
if (($comment_langcode == LANGUAGE_NONE) && variable_get('node_type_language_' . $node->type, 0)) {
if (($comment_langcode == LANGUAGE_NOT_SPECIFIED) && variable_get('node_type_language_' . $node->type, 0)) {
$comment_langcode = $language_content->langcode;
}
$form['langcode'] = array(
......@@ -1897,7 +1897,7 @@ function comment_preview($comment) {
$node = node_load($comment->nid);
if (!form_get_errors()) {
$comment->format = $comment->comment_body[LANGUAGE_NONE][0]['format'];
$comment->format = $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['format'];
// Attach the user and time information.
if (!empty($comment->name)) {
$account = user_load_by_name($comment->name);
......@@ -2014,7 +2014,7 @@ function comment_submit($comment) {
// 1) Filter it into HTML
// 2) Strip out all HTML tags
// 3) Convert entities back to plain-text.
$comment_body = $comment->comment_body[LANGUAGE_NONE][0];
$comment_body = $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0];
if (isset($comment_body['format'])) {
$comment_text = check_markup($comment_body['value'], $comment_body['format']);
}
......
......@@ -32,7 +32,7 @@ class CommentHelperCase extends DrupalWebTestCase {
* array of values to set contact info.
*/
function postComment($node, $comment, $subject = '', $contact = NULL) {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$edit = array();
$edit['comment_body[' . $langcode . '][0][value]'] = $comment;
......@@ -276,7 +276,7 @@ class CommentInterfaceTest extends CommentHelperCase {
* Tests the comment interface.
*/
function testCommentInterface() {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
// Set comments to have subject and preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
......@@ -451,8 +451,8 @@ class CommentInterfaceTest extends CommentHelperCase {
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'hostname' => ip_address(),
'langcode' => LANGUAGE_NONE,
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
'langcode' => LANGUAGE_NOT_SPECIFIED,
'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
));
comment_save($comment);
$this->drupalLogout();
......@@ -498,8 +498,8 @@ class CommentInterfaceTest extends CommentHelperCase {
'uid' => $case['comment_uid'],
'status' => $case['comment_status'],
'subject' => $this->randomName(),
'language' => LANGUAGE_NONE,
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
'language' => LANGUAGE_NOT_SPECIFIED,
'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
));
comment_save($comment);
......@@ -584,7 +584,7 @@ class CommentInterfaceTest extends CommentHelperCase {
* Tests the node comment statistics.
*/
function testCommentNodeCommentStatistics() {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
// Set comments to have subject and preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
......@@ -778,8 +778,8 @@ class CommentInterfaceTest extends CommentHelperCase {
'status' => COMMENT_PUBLISHED,
'subject' => $this->randomName(),
'hostname' => ip_address(),
'langcode' => LANGUAGE_NONE,
'comment_body' => array(LANGUAGE_NONE => array($this->randomName())),
'langcode' => LANGUAGE_NOT_SPECIFIED,
'comment_body' => array(LANGUAGE_NOT_SPECIFIED => array($this->randomName())),
));
comment_save($comment);
$this->comment = $comment;
......@@ -965,7 +965,7 @@ class CommentPreviewTest extends CommentHelperCase {
* Tests comment preview.
*/
function testCommentPreview() {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
// As admin user, configure comment settings.
$this->drupalLogin($this->admin_user);
......@@ -1012,7 +1012,7 @@ class CommentPreviewTest extends CommentHelperCase {
* Tests comment edit, preview, and save.
*/
function testCommentEditPreviewSave() {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$web_user = $this->drupalCreateUser(array('access comments', 'post comments', 'skip comment approval'));
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_OPTIONAL);
......@@ -1126,7 +1126,7 @@ class CommentAnonymous extends CommentHelperCase {
$this->assertTrue($this->commentExists($anonymous_comment2), t('Anonymous comment with contact info (optional) found.'));
// Ensure anonymous users cannot post in the name of registered users.
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$edit = array(
'name' => $this->admin_user->name,
'mail' => $this->randomName() . '@example.com',
......@@ -1522,7 +1522,7 @@ class CommentNodeAccessTest extends CommentHelperCase {
* Test that threaded comments can be viewed.
*/
function testThreadedCommentView() {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
// Set comments to have subject required and preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
......@@ -1899,7 +1899,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
$tests['[comment:mail]'] = check_plain($this->admin_user->mail);
$tests['[comment:homepage]'] = check_url($comment->homepage);
$tests['[comment:title]'] = filter_xss($comment->subject);
$tests['[comment:body]'] = _text_sanitize($instance, LANGUAGE_NONE, $comment->comment_body[LANGUAGE_NONE][0], 'value');
$tests['[comment:body]'] = _text_sanitize($instance, LANGUAGE_NOT_SPECIFIED, $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0], 'value');
$tests['[comment:url]'] = url('comment/' . $comment->cid, $url_options + array('fragment' => 'comment-' . $comment->cid));
$tests['[comment:edit-url]'] = url('comment/' . $comment->cid . '/edit', $url_options);
$tests['[comment:created:since]'] = format_interval(REQUEST_TIME - $comment->created, 2, $language_interface->langcode);
......@@ -1925,7 +1925,7 @@ class CommentTokenReplaceTestCase extends CommentHelperCase {
$tests['[comment:mail]'] = $this->admin_user->mail;
$tests['[comment:homepage]'] = $comment->homepage;
$tests['[comment:title]'] = $comment->subject;
$tests['[comment:body]'] = $comment->comment_body[LANGUAGE_NONE][0]['value'];
$tests['[comment:body]'] = $comment->comment_body[LANGUAGE_NOT_SPECIFIED][0]['value'];
$tests['[comment:parent:title]'] = $parent_comment->subject;
$tests['[comment:node:title]'] = $node->title;
$tests['[comment:author:name]'] = $this->admin_user->name;
......@@ -2140,7 +2140,7 @@ class CommentThreadingTestCase extends CommentHelperCase {
* Tests the comment threading.
*/
function testCommentThreading() {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
// Set comments to have a subject with preview disabled.
$this->drupalLogin($this->admin_user);
$this->setCommentPreview(DRUPAL_DISABLED);
......
......@@ -272,7 +272,7 @@ class DBLogTestCase extends DrupalWebTestCase {
// Create node using form to generate add content event (which is not triggered by drupalCreateNode).
$edit = $this->getContent($type);
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$title = $edit["title"];
$this->drupalPost('node/add/' . $type, $edit, t('Save'));
$this->assertResponse(200);
......@@ -327,7 +327,7 @@ class DBLogTestCase extends DrupalWebTestCase {
* @return array Content.
*/
private function getContent($type) {
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
switch ($type) {
case 'poll':
$content = array(
......@@ -363,7 +363,7 @@ class DBLogTestCase extends DrupalWebTestCase {
break;
default:
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$content = array(
"body[$langcode][0][value]" => $this->randomName(32),
);
......
......@@ -70,7 +70,7 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
'comment' => 2,
'promote' => 0,
'sticky' => 0,
'language' => LANGUAGE_NONE,
'language' => LANGUAGE_NOT_SPECIFIED,
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
);
......@@ -86,7 +86,7 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
'status' => 1,
'language' => LANGUAGE_NONE,
'language' => LANGUAGE_NOT_SPECIFIED,
));
$_SESSION['entity_crud_hook_test'] = array();
......@@ -197,7 +197,7 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
'comment' => 2,
'promote' => 0,
'sticky' => 0,
'language' => LANGUAGE_NONE,
'language' => LANGUAGE_NOT_SPECIFIED,
'created' => REQUEST_TIME,
'changed' => REQUEST_TIME,
);
......@@ -248,7 +248,7 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
$vocabulary = (object) array(
'name' => 'Test vocabulary',
'machine_name' => 'test',
'langcode' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NOT_SPECIFIED,
'description' => NULL,
'module' => 'entity_crud_hook_test',
);
......@@ -257,7 +257,7 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
$term = (object) array(
'vid' => $vocabulary->vid,
'name' => 'Test term',
'langcode' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NOT_SPECIFIED,
'description' => NULL,
'format' => 1,
);
......@@ -308,7 +308,7 @@ class EntityCrudHookTestCase extends DrupalWebTestCase {
$vocabulary = (object) array(
'name' => 'Test vocabulary',
'machine_name' => 'test',
'langcode' => LANGUAGE_NONE,
'langcode' => LANGUAGE_NOT_SPECIFIED,
'description' => NULL,
'module' => 'entity_crud_hook_test',
);
......
......@@ -104,7 +104,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$entity->ftid = $i;
$entity->fttype = ($i < 5) ? 'bundle1' : 'bundle2';
$entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i;
$entity->{$this->field_names[0]}[LANGUAGE_NOT_SPECIFIED][0]['value'] = $i;
drupal_write_record('test_entity_bundle_key', $entity);
field_attach_insert('test_entity_bundle_key', $entity);
}
......@@ -112,10 +112,10 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$entity = new stdClass();
$entity->ftid = 5;
$entity->fttype = 'test_entity_bundle';
$entity->{$this->field_names[1]}[LANGUAGE_NONE][0]['shape'] = 'square';
$entity->{$this->field_names[1]}[LANGUAGE_NONE][0]['color'] = 'red';
$entity->{$this->field_names[1]}[LANGUAGE_NONE][1]['shape'] = 'circle';
$entity->{$this->field_names[1]}[LANGUAGE_NONE][1]['color'] = 'blue';
$entity->{$this->field_names[1]}[LANGUAGE_NOT_SPECIFIED][0]['shape'] = 'square';
$entity->{$this->field_names[1]}[LANGUAGE_NOT_SPECIFIED][0]['color'] = 'red';
$entity->{$this->field_names[1]}[LANGUAGE_NOT_SPECIFIED][1]['shape'] = 'circle';
$entity->{$this->field_names[1]}[LANGUAGE_NOT_SPECIFIED][1]['color'] = 'blue';
drupal_write_record('test_entity_bundle', $entity);
field_attach_insert('test_entity_bundle', $entity);
......@@ -131,7 +131,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$entity->ftid = $i;
$entity->ftvid = $i;
$entity->fttype = 'test_bundle';
$entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i;
$entity->{$this->field_names[0]}[LANGUAGE_NOT_SPECIFIED][0]['value'] = $i;
drupal_write_record('test_entity', $entity);
field_attach_insert('test_entity', $entity);
......@@ -144,7 +144,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$entity->ftid = 4;
$entity->ftvid = $i;
$entity->fttype = 'test_bundle';
$entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i;
$entity->{$this->field_names[0]}[LANGUAGE_NOT_SPECIFIED][0]['value'] = $i;
drupal_write_record('test_entity', $entity, 'ftid');
drupal_write_record('test_entity_revision', $entity);
......@@ -981,7 +981,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$entity = new stdClass();
$entity->ftid = $i;
$entity->fttype = 'test_entity_bundle';
$entity->{$this->field_names[0]}[LANGUAGE_NONE][0]['value'] = $i - 5;
$entity->{$this->field_names[0]}[LANGUAGE_NOT_SPECIFIED][0]['value'] = $i - 5;
drupal_write_record('test_entity_bundle', $entity);
field_attach_insert('test_entity_bundle', $entity);
}
......@@ -1066,7 +1066,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$entity->fttype = 'test_bundle';
// Set fields in two languages with one field value.
foreach (array(LANGUAGE_NONE, 'en') as $langcode) {
foreach (array(LANGUAGE_NOT_SPECIFIED, 'en') as $langcode) {
$entity->{$this->field_names[0]}[$langcode][0]['value'] = 1234;
}
......@@ -1103,7 +1103,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$entity->fttype = 'test_bundle';
$j = 0;
foreach (array(LANGUAGE_NONE, 'en') as $langcode) {
foreach (array(LANGUAGE_NOT_SPECIFIED, 'en') as $langcode) {
for ($i = 0; $i < 4; $i++) {
$entity->{$this->field_names[0]}[$langcode][$i]['value'] = $i + $j;
}
......@@ -1125,7 +1125,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'test_entity', '=')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>');
->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>');
$this->assertEntityFieldQuery($query, array(
array('test_entity', 1),
), t('Test with a language meta condition.'));
......@@ -1161,7 +1161,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
$query
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', NULL, 'group')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', NULL, 'group');
->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>', NULL, 'group');
$this->assertEntityFieldQuery($query, array(), t('Test with a grouped language meta condition (empty result set).'));
// Test delta and language grouping.
......@@ -1188,7 +1188,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
->fieldDeltaCondition($this->fields[0], 1, '<', 'delta', 'language')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', 'delta', 'language');
->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>', 'delta', 'language');
$this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, language condition unsatisifed).'));
$query = new EntityFieldQuery();
......@@ -1196,7 +1196,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
->entityCondition('entity_type', 'test_entity', '=')
->fieldCondition($this->fields[0], 'value', 0, '=', 'delta', 'language')
->fieldDeltaCondition($this->fields[0], 1, '>=', 'delta', 'language')
->fieldLanguageCondition($this->fields[0], LANGUAGE_NONE, '<>', 'delta', 'language');
->fieldLanguageCondition($this->fields[0], LANGUAGE_NOT_SPECIFIED, '<>', 'delta', 'language');
$this->assertEntityFieldQuery($query, array(), t('Test with a grouped delta + language meta condition (empty result set, both conditions unsatisifed).'));
// Test grouping with another field to ensure that grouping cache is reset
......@@ -1207,7 +1207,7 @@ class EntityFieldQueryTestCase extends DrupalWebTestCase {
->fieldCondition($this->fields[1], 'shape', 'circle', '=', 'delta', 'language')
->fieldCondition($this->fields[1], 'color', 'blue', '=', 'delta', 'language')
->fieldDeltaCondition($this->fields[1], 1, '=', 'delta', 'language')
->fieldLanguageCondition($this->fields[1], LANGUAGE_NONE, '=', 'delta', 'language');
->fieldLanguageCondition($this->fields[1], LANGUAGE_NOT_SPECIFIED, '=', 'delta', 'language');
$this->assertEntityFieldQuery($query, array(
array('test_entity_bundle', 5),
), t('Test grouping cache.'));
......
......@@ -258,9 +258,9 @@ function field_default_view($entity_type, $entity, $field, $instance, $langcode,
*/
function field_default_prepare_translation($entity_type, $entity, $field, $instance, $langcode, &$items, $source_entity, $source_langcode) {
$field_name = $field['field_name'];
// If the field is untranslatable keep using LANGUAGE_NONE.
if ($langcode == LANGUAGE_NONE) {
$source_langcode = LANGUAGE_NONE;
// If the field is untranslatable keep using LANGUAGE_NOT_SPECIFIED.
if ($langcode == LANGUAGE_NOT_SPECIFIED) {
$source_langcode = LANGUAGE_NOT_SPECIFIED;
}
if (isset($source_entity->{$field_name}[$source_langcode])) {
$items = $source_entity->{$field_name}[$source_langcode];
......
......@@ -17,11 +17,12 @@
* @endcode
* Every field can hold a single or multiple value for each language belonging
* to the available languages set:
* - For untranslatable fields this set only contains LANGUAGE_NONE.
* - For untranslatable fields this set only contains LANGUAGE_NOT_SPECIFIED.
* - For translatable fields this set can contain any language code. By default
* it is the list returned by field_content_languages(), which contains all
* installed languages with the addition of LANGUAGE_NONE. This default can be
* altered by modules implementing hook_field_available_languages_alter().
* installed languages with the addition of LANGUAGE_NOT_SPECIFIED. This
* default can be altered by modules implementing
* hook_field_available_languages_alter().
*
* The available languages for a particular field are returned by
* field_available_languages(). Whether a field is translatable is determined by
......@@ -87,10 +88,10 @@ function field_language_delete() {
* Collects the available languages for the given entity type and field.
*
* If the given field has language support enabled, an array of available
* languages will be returned, otherwise only LANGUAGE_NONE will be returned.
* Since the default value for a 'translatable' entity property is FALSE, we
* ensure that only entities that are able to handle translations actually get
* translatable fields.
* languages will be returned, otherwise only LANGUAGE_NOT_SPECIFIED will be
* returned. Since the default value for a 'translatable' entity property is
* FALSE, we ensure that only entities that are able to handle translations
* actually get translatable fields.
*
* @param $entity_type
* The type of the entity the field is attached to, e.g. 'node' or 'user'.
......@@ -110,7 +111,7 @@ function field_available_languages($entity_type, $field) {
if (!isset($field_languages[$entity_type][$field_name])) {
// If the field has language support enabled we retrieve an (alterable) list
// of enabled languages, otherwise we return just LANGUAGE_NONE.
// of enabled languages, otherwise we return just LANGUAGE_NOT_SPECIFIED.
if (field_is_translatable($entity_type, $field)) {
$languages = field_content_languages();
// Let other modules alter the available languages.
......@@ -119,7 +120,7 @@ function field_available_languages($entity_type, $field) {
$field_languages[$entity_type][$field_name] = $languages;
}
else {
$field_languages[$entity_type][$field_name] = array(LANGUAGE_NONE);
$field_languages[$entity_type][$field_name] = array(LANGUAGE_NOT_SPECIFIED);
}
}
......@@ -163,13 +164,14 @@ function _field_language_suggestion($available_languages, $language_suggestion,
/**
* Returns available content languages.
*
* The languages that may be associated to fields include LANGUAGE_NONE.
* The languages that may be associated to fields include
* LANGUAGE_NOT_SPECIFIED.
*
* @return
* An array of language codes.
*/
function field_content_languages() {
return array_keys(language_list() + array(LANGUAGE_NONE => NULL));
return array_keys(language_list() + array(LANGUAGE_NOT_SPECIFIED => NULL));
}
/**
......@@ -254,8 +256,9 @@ function field_valid_language($langcode, $default = TRUE) {
* The actual language for each given field is determined based on the requested
* language and the actual data available in the fields themselves.
* If there is no registered translation handler for the given entity type, the
* display language to be used is just LANGUAGE_NONE, as no other language code
* is allowed by field_available_languages().
* display language to be used is just LANGUAGE_NOT_SPECIFIED, as no other
* language code is allowed by field_available_languages().
*
* If translation handlers are found, we let modules provide alternative display
* languages for fields not having the requested language available.
* Core language fallback rules are provided by locale_field_language_fallback()
......@@ -285,11 +288,11 @@ function field_language($entity_type, $entity, $field_name = NULL, $langcode = N
if (!isset($display_languages[$entity_type][$id][$langcode])) {
$display_language = array();
// By default display language is set to LANGUAGE_NONE if the field
// By default display language is set to LANGUAGE_NOT_SPECIFIED if the field
// translation is not available. It is up to translation handlers to
// implement language fallback rules.
foreach (field_info_instances($entity_type, $bundle) as $instance) {
$display_language[$instance['field_name']] = isset($entity->{$instance['field_name']}[$langcode]) ? $langcode : LANGUAGE_NONE;
$display_language[$instance['field_name']] = isset($entity->{$instance['field_name']}[$langcode]) ? $langcode : LANGUAGE_NOT_SPECIFIED;
}
if (field_has_translation_handler($entity_type)) {
......
......@@ -45,7 +45,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
function testFieldAttachLoad() {
$entity_type = 'test_entity';
$eid = 0;
$langcode = LANGUAGE_NONE;
$langcode = LANGUAGE_NOT_SPECIFIED;
$columns = array('entity_type', 'entity_id', 'revision_id', 'delta', 'language', $this->field_name . '_value');
......@@ -113,7 +113,7 @@ class FieldSqlStorageTestCase extends DrupalWebTestCase {
function testFieldAttachInsertAndUpdate() {
$entity_type = 'test_entity';
$entity = field_test_create_stub_entity(0, 0, $this->instance['bundle']);