2

I have a bilingual site and I want to redirect to a custom page, which has two language versions, upon form submitting. This may be a pretty basic thing, but I am only starting to learn how to code for Drupal in PHP. This is what I tried:

$form_state['redirect'] = t('message-sent-successfully');

'message-sent-successfully' is the URL for the English version of the page. It has a different URL for the other language the site is using. In whatever language I submit the form, I get redirected to the above URL, i.e. the url doesn't get translated.

  • Using node/[nid] instead should solve this problem; the user should be redirected to the proper alias of the node, translated in the currently active language. – Aram Boyajyan Apr 10 '14 at 11:04
  • I just tried this and the two translations have two different node ID's which is quite a surprise to me. – alouette Apr 10 '14 at 11:51
  • Hm, I might be mistaken - will check it now quickly. – Aram Boyajyan Apr 10 '14 at 12:48
  • This works as I mentioned, but you need to have i18n module + globalredirect configured; will post it as an answer as there isn't enough space here. – Aram Boyajyan Apr 10 '14 at 13:12
0

Install i18n and enable the Translation Redirect module within.

Install Globalredirect and go to admin/config/system/globalredirect and check "Language path checking".

You can then take the user to either source or translated node, and Globalredirect will take the user to the page which is in the currently active language.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.