diff options
author | David Rothstein <drothstein@gmail.com> | 2012-06-09 15:51:03 -0400 |
---|---|---|
committer | David Rothstein <drothstein@gmail.com> | 2012-06-09 15:51:03 -0400 |
commit | a12152309a64b5c3b9ea6a41e8da2baa9971f612 (patch) | |
tree | a6f27f9eced00ca14d8510be57e4d2e7588d968a /modules/translation | |
parent | 4a60f552b4e03916c76bbc7aaea5bc3fa503e85d (diff) | |
download | brdo-a12152309a64b5c3b9ea6a41e8da2baa9971f612.tar.gz brdo-a12152309a64b5c3b9ea6a41e8da2baa9971f612.tar.bz2 |
Issue #1495648 by plach: Introduce entity language support.
Diffstat (limited to 'modules/translation')
-rw-r--r-- | modules/translation/translation.module | 20 | ||||
-rw-r--r-- | modules/translation/translation.pages.inc | 2 | ||||
-rw-r--r-- | modules/translation/translation.test | 2 |
3 files changed, 14 insertions, 10 deletions
diff --git a/modules/translation/translation.module b/modules/translation/translation.module index e61be1d66..331235705 100644 --- a/modules/translation/translation.module +++ b/modules/translation/translation.module @@ -84,7 +84,7 @@ function translation_menu() { * @see translation_menu() */ function _translation_tab_access($node) { - if ($node->language != LANGUAGE_NONE && translation_supported_type($node->type) && node_access('view', $node)) { + if (entity_language('node', $node) != LANGUAGE_NONE && translation_supported_type($node->type) && node_access('view', $node)) { return user_access('translate content'); } return FALSE; @@ -233,7 +233,7 @@ function translation_node_view($node, $view_mode) { foreach ($translations as $langcode => $translation) { // Do not show links to the same node, to unpublished translations or to // translations in disabled languages. - if ($translation->status && isset($languages[$langcode]) && $langcode != $node->language) { + if ($translation->status && isset($languages[$langcode]) && $langcode != entity_language('node', $node)) { $language = $languages[$langcode]; $key = "translation_$langcode"; @@ -313,7 +313,7 @@ function translation_node_prepare($node) { // Add field translations and let other modules module add custom translated // fields. - field_attach_prepare_translation('node', $node, $node->language, $source_node, $source_node->language); + field_attach_prepare_translation('node', $node, $langcode, $source_node, $source_node->language); } } @@ -358,7 +358,8 @@ function translation_node_insert($node) { function translation_node_update($node) { // Only act if we are dealing with a content type supporting translations. if (translation_supported_type($node->type)) { - if (isset($node->translation) && $node->translation && !empty($node->language) && $node->tnid) { + $langcode = entity_language('node', $node); + if (isset($node->translation) && $node->translation && !empty($langcode) && $node->tnid) { // Update translation information. db_update('node') ->fields(array( @@ -389,7 +390,8 @@ function translation_node_validate($node, $form) { if (translation_supported_type($node->type) && (!empty($node->tnid) || !empty($form['#node']->translation_source->nid))) { $tnid = !empty($node->tnid) ? $node->tnid : $form['#node']->translation_source->nid; $translations = translation_node_get_translations($tnid); - if (isset($translations[$node->language]) && $translations[$node->language]->nid != $node->nid ) { + $langcode = entity_language('node', $node); + if (isset($translations[$langcode]) && $translations[$langcode]->nid != $node->nid ) { form_set_error('language', t('There is already a translation in this language.')); } } @@ -469,7 +471,8 @@ function translation_node_get_translations($tnid) { ->execute(); foreach ($result as $node) { - $translations[$tnid][$node->language] = $node; + $langcode = entity_language('node', $node); + $translations[$tnid][$langcode] = $node; } } return $translations[$tnid]; @@ -523,10 +526,11 @@ function translation_language_switch_links_alter(array &$links, $type, $path) { // have translations it might be a language neutral node, in which case we // must leave the language switch links unaltered. This is true also for // nodes not having translation support enabled. - if (empty($node) || $node->language == LANGUAGE_NONE || !translation_supported_type($node->type)) { + if (empty($node) || entity_language('node', $node) == LANGUAGE_NONE || !translation_supported_type($node->type)) { return; } - $translations = array($node->language => $node); + $langcode = entity_language('node', $node); + $translations = array($langcode => $node); } else { $translations = translation_node_get_translations($node->tnid); diff --git a/modules/translation/translation.pages.inc b/modules/translation/translation.pages.inc index fa4070bb8..110fea603 100644 --- a/modules/translation/translation.pages.inc +++ b/modules/translation/translation.pages.inc @@ -27,7 +27,7 @@ function translation_node_overview($node) { else { // We have no translation source nid, this could be a new set, emulate that. $tnid = $node->nid; - $translations = array($node->language => $node); + $translations = array(entity_language('node', $node) => $node); } $type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE); diff --git a/modules/translation/translation.test b/modules/translation/translation.test index 09bc9e3b9..e64f9cb86 100644 --- a/modules/translation/translation.test +++ b/modules/translation/translation.test @@ -429,7 +429,7 @@ class TranslationTestCase extends DrupalWebTestCase { $result = TRUE; $languages = language_list(); - $page_language = $languages[$node->language]; + $page_language = $languages[entity_language('node', $node)]; $translation_language = $languages[$translation->language]; $url = url("node/$translation->nid", array('language' => $translation_language)); |