summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2010-08-05 08:08:43 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2010-08-05 08:08:43 +0000
commite574bcffcebf168a8b2f329b2eea8269f494be6c (patch)
tree9e50d7874454a9fe4ee52dc92ad153a6c9a63372
parentf1b30b89c59127ea787bafd7da6b06f0266d4bb2 (diff)
downloadbrdo-e574bcffcebf168a8b2f329b2eea8269f494be6c.tar.gz
brdo-e574bcffcebf168a8b2f329b2eea8269f494be6c.tar.bz2
#835212 by plach, jhodgdon: Fixed locale_url_outbound_alter() should be run only on multilingual sites.
-rw-r--r--modules/locale/locale.module2
-rw-r--r--modules/path/path.test62
-rw-r--r--modules/translation/translation.module2
3 files changed, 64 insertions, 2 deletions
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index f76d4ebb3..f7606a0f3 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -961,7 +961,7 @@ function locale_block_view($type) {
*/
function locale_url_outbound_alter(&$path, &$options, $original_path) {
// Only modify internal URLs.
- if (!$options['external']) {
+ if (!$options['external'] && drupal_multilingual()) {
static $callbacks;
if (!isset($callbacks)) {
diff --git a/modules/path/path.test b/modules/path/path.test
index 6584eda6b..cca5fd972 100644
--- a/modules/path/path.test
+++ b/modules/path/path.test
@@ -440,3 +440,65 @@ class PathLanguageUITestCase extends DrupalWebTestCase {
}
}
+
+/**
+ * Tests that paths are not prefixed on a monolingual site.
+ */
+class PathMonolingualTestCase extends DrupalWebTestCase {
+ public static function getInfo() {
+ return array(
+ 'name' => 'Paths on non-English monolingual sites',
+ 'description' => 'Confirm that paths are not changed on monolingual non-English sites',
+ 'group' => 'Path',
+ );
+ }
+
+ function setUp() {
+ global $language;
+ parent::setUp('path', 'locale', 'translation');
+
+ // Create and login user.
+ $web_user = $this->drupalCreateUser(array('administer languages', 'access administration pages'));
+ $this->drupalLogin($web_user);
+
+ // Enable French language.
+ $edit = array();
+ $edit['langcode'] = 'fr';
+ $this->drupalPost('admin/config/regional/language/add', $edit, t('Add language'));
+
+ // Make French the default language.
+ $edit = array('site_default' => 'fr');
+ $this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
+
+ // Disable English.
+ $edit = array('enabled[en]' => FALSE);
+ $this->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));
+
+ // Verify that French is the only language.
+ $this->assertFalse(drupal_multilingual(), t('Site is mono-lingual'));
+ $this->assertEqual(language_default('language'), 'fr', t('French is the default language'));
+
+ // Set language detection to URL.
+ $edit = array('language[enabled][locale-url]' => TRUE);
+ $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
+
+ // Force languages to be initialized.
+ drupal_language_initialize();
+ }
+
+ /**
+ * Verifies that links do not have language prefixes in them.
+ */
+ function testPageLinks() {
+ // Navigate to 'admin/config' path.
+ $this->drupalGet('admin/config');
+
+ // Verify that links in this page do not have a 'fr/' prefix.
+ $this->assertNoLinkByHref('/fr/', 'Links do not contain language prefix');
+
+ // Verify that links in this page can be followed and work.
+ $this->clickLink(t('Languages'));
+ $this->assertResponse(200, 'Clicked link results in a valid page');
+ $this->assertText(t('Add language'), 'Page contains the add language text');
+ }
+}
diff --git a/modules/translation/translation.module b/modules/translation/translation.module
index 75b0bdede..0a90d115b 100644
--- a/modules/translation/translation.module
+++ b/modules/translation/translation.module
@@ -181,7 +181,7 @@ function translation_form_alter(&$form, &$form_state, $form_id) {
* is part of a translation set.
*/
function translation_node_view($node, $view_mode) {
- if (isset($node->tnid) && $translations = translation_node_get_translations($node->tnid)) {
+ if (isset($node->tnid) && drupal_multilingual() && $translations = translation_node_get_translations($node->tnid)) {
$path = 'node/' . $node->nid;
$links = language_negotiation_get_switch_links(LANGUAGE_TYPE_INTERFACE, $path);
if (is_object($links)) {