Problem/Motivation
It seems that calls like /fr/js/teaser_region_front?js_theme=my_theme&js_module=my_module&js_callback=teaser_region_front&js_token=&items=2&arguments=
loose the language prefix.
The url is created using $(this).jsCallback('my_module', 'teaser_region_front',{})
so I guess it fits the API.
Unfortunately js_update_path()
doesn't seem to take the language prefix in account. The language prefix is properly detected in js_execute_request()
and stored in the global $_js['lang']
.
However rebuilding the path in js_update_path()
ignores the path prefix.
js_update_path()
was introduced by #2724737: Always update path when bootstrap level is DRUPAL_BOOTSTRAP_LANGUAGE and above which basically was also about fixing the path prefix I just can speculate that this was about paths like js/fr/my_callback?js_....
because js_update_path()
works perfectly for such a scenario.
Proposed resolution
I suggest to modify js_update_path()
to check if $_js['lang']
exists and if so add it as prefix.
If that's not viable I assume the code in js.js
has to be adjusted to put the endpoint before the path prefix.
Attached patch uses the former approach.
Remaining tasks
Reviews needed.
User interface changes
None.
API changes
None. Same to use as before just supports fr/js/callbaccky
and js/fr/callback
.
Data model changes
None.
Comment | File | Size | Author |
---|---|---|---|
#4 | js-url_language_prefix-2850287-4.patch | 603 bytes | plach |
js-language_path_prefix.patch | 555 bytes | das-peter |
Comments
Comment #3
markhalliwellComment #4
plachThis caused a regression with some
jsGet
calls in our custom code: the server was returning the following error:The requested URL "/en/en/..." could not be found.
. The attached patch fixed the issue.Comment #6
markhalliwell