diff --git a/core/includes/locale.inc b/core/includes/locale.inc index e2a79b6..1afe588 100644 --- a/core/includes/locale.inc +++ b/core/includes/locale.inc @@ -439,7 +439,7 @@ function locale_language_url_rewrite_url(&$path, &$options) { if (!empty($domains[$options['language']->langcode])) { // Ask for an absolute URL with our modified base_url. $options['absolute'] = TRUE; - $options['base_url'] = $domains[$options['language']->langcode]; + $options['base_url'] = 'http://' . $domains[$options['language']->langcode]; } break; diff --git a/core/modules/locale/locale.test b/core/modules/locale/locale.test index f102d4b..170f230 100644 --- a/core/modules/locale/locale.test +++ b/core/modules/locale/locale.test @@ -2212,6 +2212,42 @@ class LocaleUILanguageNegotiationTest extends DrupalWebTestCase { $fields = $this->xpath('//div[@id="site-name"]//a[@rel="home" and @href=:url]//span', $args); $this->assertTrue($fields[0] == 'Drupal', t('URLs are rewritten using the browser language.')); } + + /** + * Test if the url function returns the right url when using different domains for different languages. + */ + function testLanguageDomain() { + // Add the Italian language. + $langcode_browser_fallback = 'it'; + $language = (object) array( + 'langcode' => $langcode_browser_fallback, + ); + language_save($language); + $languages = language_list(); + + // Enable browser and URL language detection. + $edit = array( + 'language[enabled][locale-browser]' => TRUE, + 'language[enabled][locale-url]' => TRUE, + 'language[weight][locale-browser]' => -8, + 'language[weight][locale-url]' => -10, + ); + $this->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings')); + + // Change the domain for the Italian language. + $edit = array( + 'locale_language_negotiation_url_part' => 1, + 'domain[it]' => 'it.example.com', + ); + $this->drupalPost('admin/config/regional/language/configure/url', $edit, t('Save configuration')); + + // Test URL in another language: http://it.example.com/?q=admin + // Base path gives problems on the testbot, so $correct_link is hard-coded + // @see UrlAlterFunctionalTest::assertUrlOutboundAlter (path.test) + $italian_url = url('admin', array('language' => $languages['it'])); + $correct_link = 'http://it.example.com/?q=admin'; + $this->assertTrue($italian_url == $correct_link, t('The url() function returns the right url in accordance with the chosen language')); + } } /**