Hi friends,
I am working on a D7 multilingual site which have many languages - english, french, dutch etc.
I am trying to redirect the user to an internal path as
drupal_goto('my-internal-path', array('query' => drupal_get_destination());
It is giving -- http://www.example.com/en/my-internal-path?destination=my-current-path
Here destination parameter is working but taking language as default which is 'en' in my case and giving 404 as the internal path is of french language, and I want it to be 'fr'.
So I used --
drupal_goto('my-internal-path', array('query' => drupal_get_destination(), 'language' => (object)array('language' => 'fr')));
Now, the page is redirecting properly to fr page, but the destination parameter gets removed.
The url get become --
http://www.example.com/fr/my-internal-path
but I want like,
http://www.example.com/fr/my-internal-path?destination=my-current-path
I tried many different thing, but the query and language parameter are not working together in drupal_goto,
Not sure, I am trying something wrong
any solution will be helpful.
Regards
Sunil Singh
Comments
i have same problem, here is
i have same problem, here is the solution
$node = node_load($nid);
$nodeTranslation = $node->translations->data;
$default_lang = $node->translations->original;
$selected_lang = $language->language;
$check_language = array_key_exists($selected_lang, $nodeTranslation);
if (array_key_exists($selected_lang, $nodeTranslation))
{
$content_language = $selected_lang;
}
else
{
$content_language = $default_lang;
}
use $content_language parameter in drupal_goto that will fix your problem.