summaryrefslogtreecommitdiff
path: root/modules/translation
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-22 06:14:55 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-11-22 06:14:55 +0000
commit9463ec1d400f79e08dab3ff438b6a0c0576ec136 (patch)
tree0020866aea6506f219820bc7a5aeda5a7b483978 /modules/translation
parenta61d3660236ac6bc3a39f413400bfebad24745c1 (diff)
downloadbrdo-9463ec1d400f79e08dab3ff438b6a0c0576ec136.tar.gz
brdo-9463ec1d400f79e08dab3ff438b6a0c0576ec136.tar.bz2
#284625 by bforchhammer, plach: Fixed Non-localized links in translation table
Diffstat (limited to 'modules/translation')
-rw-r--r--modules/translation/translation.pages.inc22
-rw-r--r--modules/translation/translation.test22
2 files changed, 37 insertions, 7 deletions
diff --git a/modules/translation/translation.pages.inc b/modules/translation/translation.pages.inc
index 5c6add4b6..0343b49f4 100644
--- a/modules/translation/translation.pages.inc
+++ b/modules/translation/translation.pages.inc
@@ -24,18 +24,24 @@ function translation_node_overview($node) {
$translations = array($node->language => $node);
}
+ $type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
$header = array(t('Language'), t('Title'), t('Status'), t('Operations'));
- foreach (language_list() as $language) {
+ foreach (language_list() as $langcode => $language) {
$options = array();
$language_name = $language->name;
- if (isset($translations[$language->language])) {
+ if (isset($translations[$langcode])) {
// Existing translation in the translation set: display status.
// We load the full node to check whether the user can edit it.
- $translation_node = node_load($translations[$language->language]->nid);
- $title = l($translation_node->title, 'node/' . $translation_node->nid);
+ $translation_node = node_load($translations[$langcode]->nid);
+ $path = 'node/' . $translation_node->nid;
+ $links = language_negotiation_get_switch_links($type, $path);
+ $title = empty($links->links[$langcode]) ? l($translation_node->title, $path) : l($translation_node->title, $links->links[$langcode]['href'], $links->links[$langcode]);
if (node_access('update', $translation_node)) {
- $options[] = l(t('edit'), "node/$translation_node->nid/edit");
+ $text = t('edit');
+ $path = 'node/' . $translation_node->nid . '/edit';
+ $links = language_negotiation_get_switch_links($type, $path);
+ $options[] = empty($links->links[$langcode]) ? l($text, $path) : l($text, $links->links[$langcode]['href'], $links->links[$langcode]);
}
$status = $translation_node->status ? t('Published') : t('Not published');
$status .= $translation_node->translate ? ' - <span class="marker">' . t('outdated') . '</span>' : '';
@@ -47,7 +53,11 @@ function translation_node_overview($node) {
// No such translation in the set yet: help user to create it.
$title = t('n/a');
if (node_access('create', $node)) {
- $options[] = l(t('add translation'), 'node/add/' . str_replace('_', '-', $node->type), array('query' => array('translation' => $node->nid, 'target' => $language->language)));
+ $text = t('add translation');
+ $path = 'node/add/' . str_replace('_', '-', $node->type);
+ $links = language_negotiation_get_switch_links($type, $path);
+ $query = array('query' => array('translation' => $node->nid, 'target' => $langcode));
+ $options[] = empty($links->links[$langcode]) ? l($text, $path, $query) : l($text, $links->links[$langcode]['href'], array_merge_recursive($links->links[$langcode], $query));
}
$status = t('Not translated');
}
diff --git a/modules/translation/translation.test b/modules/translation/translation.test
index 1e7bf61d6..7148db12b 100644
--- a/modules/translation/translation.test
+++ b/modules/translation/translation.test
@@ -25,6 +25,13 @@ class TranslationTestCase extends DrupalWebTestCase {
$this->addLanguage('en');
$this->addLanguage('es');
+ // Enable language negotiation using path-prefix
+ $this->drupalGet('admin/config/regional/language/configure');
+ $edit = array();
+ $edit['language[enabled][locale-url]'] = 1;
+ $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
+ $this->assertRaw(t('Language negotiation configuration saved.'), t('URL language detection enabled.'));
+
// Set "Basic page" content type to use multilingual support with translation.
$this->drupalGet('admin/structure/types/manage/page');
$edit = array();
@@ -45,14 +52,23 @@ class TranslationTestCase extends DrupalWebTestCase {
$node_body = $this->randomName();
$node = $this->createPage($node_title, $node_body, 'en');
+ // Check that the "add translation" link uses a localized path
+ $languages = language_list();
+ $this->drupalGet('node/' . $node->nid . '/translate');
+ $this->assertLinkByHref($languages['es']->prefix . '/node/add/' . str_replace('_', '-', $node->type), 0, t('The "add translation" link for %language points to the localized path of the target language.', array('%language' => $languages['es']->name)));
+
// Submit translation in Spanish.
$node_translation_title = $this->randomName();
$node_translation_body = $this->randomName();
$node_translation = $this->createTranslation($node, $node_translation_title, $node_translation_body, 'es');
+ // Check that the "edit translation" and "view node" links use localized paths.
+ $this->drupalGet('node/' . $node->nid . '/translate');
+ $this->assertLinkByHref($languages['es']->prefix . '/node/' . $node_translation->nid . '/edit', 0, t('The "edit" link for the translation in %language points to the localized path of the translation language.', array('%language' => $languages['es']->name)));
+ $this->assertLinkByHref($languages['es']->prefix . '/node/' . $node_translation->nid, 0, t('The "view" link for the translation in %language points to the localized path of the translation language.', array('%language' => $languages['es']->name)));
+
// Attempt to submit a duplicate translation by visiting the node/add page
// with identical query string.
- $languages = language_list();
$this->drupalGet('node/add/page', array('query' => array('translation' => $node->nid, 'target' => 'es')));
$this->assertRaw(t('A translation of %title in %language already exists', array('%title' => $node_title, '%language' => $languages['es']->name)), t('Message regarding attempted duplicate translation is displayed.'));
@@ -118,6 +134,10 @@ class TranslationTestCase extends DrupalWebTestCase {
// Check that content translation links are shown even when no language
// negotiation is configured.
+ $this->drupalLogin($this->admin_user);
+ $edit = array('language[enabled][locale-url]' => FALSE);
+ $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
+ $this->drupalLogin($this->translator);
$languages = language_list();
$this->drupalGet("node/$node->nid");
$url = url("node/$node_translation->nid");