Commit 22ca7bc3 authored by alexpott's avatar alexpott

Issue #2146035 by olli, mondrake: Fixed drupalSettings.path.pathPrefix does...

Issue #2146035 by olli, mondrake: Fixed drupalSettings.path.pathPrefix does not contain the language identifier.
parent 53b024db
......@@ -188,6 +188,7 @@ public function generate($name, $parameters = array(), $absolute = FALSE) {
* {@inheritdoc}
*/
public function generateFromRoute($name, $parameters = array(), $options = array()) {
$options += array('prefix' => '');
$absolute = !empty($options['absolute']);
$route = $this->getRoute($name);
$this->processRoute($route, $parameters);
......@@ -199,6 +200,12 @@ public function generateFromRoute($name, $parameters = array(), $options = array
$path = $this->getInternalPathFromRoute($route, $parameters);
$path = $this->processPath($path, $options);
if (!empty($options['prefix'])) {
$path = ltrim($path, '/');
$prefix = empty($path) ? rtrim($options['prefix'], '/') : $options['prefix'];
$path = '/' . str_replace('%2F', '/', rawurlencode($prefix)) . $path;
}
$fragment = '';
if (isset($options['fragment'])) {
if (($fragment = trim($options['fragment'])) != '') {
......
......@@ -127,6 +127,8 @@ public function getPathFromRoute($name, $parameters = array());
* defined, the current scheme is used, so the user stays on HTTP or HTTPS
* respectively. if mixed mode sessions are permitted, TRUE enforces HTTPS
* and FALSE enforces HTTP.
* - 'prefix': Only used internally, to modify the path when a language
* dependent URL requires so.
*
* @return string
* The generated URL for the given route.
......
......@@ -326,7 +326,7 @@ if (window.jQuery) {
* Returns the URL to a Drupal page.
*/
Drupal.url = function (path) {
return drupalSettings.path.basePath + drupalSettings.path.scriptPath + path;
return drupalSettings.path.basePath + drupalSettings.path.scriptPath + drupalSettings.path.pathPrefix + path;
};
/**
......
......@@ -141,7 +141,7 @@ public function processOutbound($path, &$options = array(), Request $request = N
$config = $this->config->get('language.negotiation')->get('url');
if ($config['source'] == LanguageNegotiationUrl::CONFIG_PATH_PREFIX) {
if (is_object($options['language']) && !empty($config['prefixes'][$options['language']->id])) {
return empty($path) ? $config['prefixes'][$options['language']->id] : $config['prefixes'][$options['language']->id] . '/' . $path;
$options['prefix'] = $config['prefixes'][$options['language']->id] . '/';
}
}
elseif ($config['source'] == LanguageNegotiationUrl::CONFIG_DOMAIN) {
......
......@@ -41,6 +41,9 @@ function setUp() {
$edit = array('language_interface[enabled][language-url]' => 1);
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Check that drupalSettings contains path prefix.
$this->drupalGet('fr/admin/config/regional/language/detection');
$this->assertRaw('"pathPrefix":"fr\/"', 'drupalSettings path prefix contains language code.');
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment