Hi there,

I have views with AJAXed mini pager. I also use i18n (Internationalization) module.
All work fine except using non-default language (when links become prefixed with it).
Then ajax_path also gets prefixed and looks like: "ajax_path": [ "/de/views/ajax", "/de/views/ajax", "/de/views/ajax" ] which leads to empty block when I click pager links.

When I remove the language prefix it works fine again, of course it works fine without AJAX.

I've changed 'ajax_path' => url('views/ajax') to
'ajax_path' => url('views/ajax', array('language' => array('prefix' => ''))) in views/theme/theme.inc, can it break anything?

Regards

Comments

serg.remote’s picture

UPD: Another problem I've run in is that if you click on Previous-Next links directly it doesn't consider your current language, however if you copy the link, paste it to browser URL and open manually it does.
Any idea where to dig it?

merlinofchaos’s picture

Unfortunately,I don't understand what i18n does to links to make all of this stuff happen, so I am going to need someone really familiar with that code to advise me as to why this stuff isn't working automatically.

serg.remote’s picture

Status: Active » Closed (fixed)

Seem to be fixed with i18n-6.x-1.0-beta6

daniel wentsch’s picture

I guess I'm experiencing the exact same problem right now, although using the most recent version 6.x-1.2 of i18n.
Can somebody reproduce this?
First I thought the problem was this: http://drupal.org/node/659510#comment-2562832

But today I found out that AJAX paging without language path prefixes does work, with path prefixes it doesn't and views_args aren't set properly.

digidoo’s picture

I can confirm #4, having the same problem here since updating.
With language path prefix the ajax paging won't work (eg. glossary), without in default language everything is fine.

udig’s picture

subscribe

serg.remote’s picture

Status: Closed (fixed) » Active

Could you tell versions of i18n and Views modules you experience this issue with?

digidoo’s picture

Yes, these are the versions:

Internationalization 6.x-1.2
Views 6.x-2.8

serg.remote’s picture

Version: 6.x-2.1 » 6.x-2.8
edrauta’s picture

I can confirm the problem.

the versions of modules are:

views 6.x.2.10
I18n 6.x.14

eloivaque’s picture

Version: 6.x-2.8 » 6.x-2.10

Subscribe de problem.

The views glossary with ajax on, do work. But if install i18n and active "Path prefix only" or "Path prefix with language fallback" do not work.

I try change the path of ajax_path, but no work.

merlinofchaos’s picture

Status: Active » Closed (won't fix)

I'm afraid I can't support i18n module; if the error happens only with i18n enabled, then the issue needs to go there. If indeed it is a problem with Views, someone with familiarity with i18n can tell me what's wrong, which is precisely what the submission guidelines say to do.

fmjrey’s picture

I'm also having this issue on glossary.
This may be the related i18n bug:
http://drupal.org/node/721300

edrauta’s picture

I worked my way:

file -> views.module

function views_init() {
  drupal_add_css(drupal_get_path('module', 'views') . '/css/views.css');
	
	+// Custom code
	+global $language;
	+drupal_add_js("var language_negotiation = " . drupal_to_js(variable_get('language_negotiation', '')) . ";", 'inline');
	+drupal_add_js("var language = " . drupal_to_js($language->language) . ";", 'inline');
	+// END Custom code
}

file ->/js/base.js

Drupal.Views.getPath = function (href) {
  href = Drupal.Views.pathPortion(href);
  href = href.substring(Drupal.settings.basePath.length, href.length);
  // 3 is the length of the '?q=' added to the url without clean urls.
  if (href.substring(0, 3) == '?q=') {
    href = href.substring(3, href.length);
  }

+// custom code
+if(language_negotiation == 2){
+	href = href.substring(language.length+1, href.length);
+}
+// END custom code
	
  var chars = ['#', '?', '&'];
  for (i in chars) {
    if (href.indexOf(chars[i]) > -1) {
      href = href.substr(0, href.indexOf(chars[i]));
    }
  }
  return href;
};

I delete prefix of language negotiation in the path.

Marko B’s picture

#14 didnt worked for me on.

manos_ws’s picture

The patch in #14 works but it doesn't take in consideration the languages that doesn't have a prefix set.

Usually in a multilingual site we have the default language without prefix and the others with prefixes.
so the above code in #14 should be changed to

file -> views.module

function views_init() {
  drupal_add_css(drupal_get_path('module', 'views') . '/css/views.css');
	
+	// Custom code
+	global $language;
+	if (!empty($language->prefix)){
+		drupal_add_js("var language_negotiation = " . drupal_to_js(variable_get('language_negotiation', '')) . ";", 'inline');
+		drupal_add_js("var language = " . drupal_to_js($language->language) . ";", 'inline');
+	}
+	else{
+			drupal_add_js("var language_negotiation = 0 ;", 'inline');
+	}
+	// END Custom code

}

And the
file ->/js/base.js
as in #14

Thanks.

corbacho’s picture

subscribing

manos_ws’s picture

I found another problem with the above solution. It only works when the Language negotiation is set to "Path prefix with language fallback."
I wanted to use boost so I had to use "Path prefix only"

So the above code becomes:
file -> views.module

function views_init() {
  drupal_add_css(drupal_get_path('module', 'views') . '/css/views.css');
	
+	// Custom code
+	global $language;
+	if (!empty($language->prefix)){
+		drupal_add_js("var language_negotiation = " . drupal_to_js(variable_get('language_negotiation', '')) . ";", 'inline');
+		drupal_add_js("var language = " . drupal_to_js($language->language) . ";", 'inline');
+	}
+	else{
+			drupal_add_js("var language_negotiation = -1 ;", 'inline');
+	}
+	// END Custom code

}

and the
file ->/js/base.js

Drupal.Views.getPath = function (href) {
  href = Drupal.Views.pathPortion(href);
  href = href.substring(Drupal.settings.basePath.length, href.length);
  // 3 is the length of the '?q=' added to the url without clean urls.
  if (href.substring(0, 3) == '?q=') {
    href = href.substring(3, href.length);
  }

+// custom code
+if(language_negotiation == 1 || language_negotiation == 2){
+	href = href.substring(language.length+1, href.length);
+}
+// END custom code
	
  var chars = ['#', '?', '&'];
  for (i in chars) {
    if (href.indexOf(chars[i]) > -1) {
      href = href.substr(0, href.indexOf(chars[i]));
    }
  }
  return href;
};

Probably it should be fixed for Language negotiation set to "None" and "Domain name only"

Could someone with better knowledge than me in Language negotiation give a complete solution ?
Thanks