Choosing language from another website

Choosing language from another website

by Wonton Sopabuena -
Number of replies: 4

Hello everyone!

I have a website developed with Drupal. This site is multilingual, and the user can choose between English (by default) and Spanish.

In this website, I have a link to my Moodle site. My Drupal site is www.example.com and my Moodle site is www.example.com/moodle.

My Moodle site is "multilingual" too, the user can choose between English (by default) and Spanish.

Here it comes my problem. If a user chooses Spanish in Drupal and click in the Moodle link he is redirected to the Moodle login in English, not in Spanish. I know it's logical, but, is there any way to make that Moodle shows the same language that the user had selected in Drupal?

I'm computer scientist but I know PHP since a few months, so I'm almost a newby with it. I think is imposible that Moodle knows the language selected in Drupal, but any of you could find a solution to my problem?

I've even thought in having two different Moodle instalation, one only in English and the other one only in Spanish, and that Drupal links to the correct one, but I know this is an awful solution.

Any suggestion?

Thank you very much!

wonton

Average of ratings: -
In reply to Wonton Sopabuena

Re: Choosing language from another website

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
Hi Wonton,

there is such a way. You have to solve it at the Drupal site and have two links according to the current language. Then, you can send an information about the selected language in the "lang" parameter, eg:

http://my.moodle.dtl/?lang=en (will open Moodle in the English)
http://my.moodle.dtl/?lang=es (will open Moodle in the Spanish)

HTH
In reply to David Mudrák

Re: Choosing language from another website

by Wonton Sopabuena -

¡Perfect! big grin

Thank you very much David!

Just one question. I have some links to courses, not to the login page, links like this:

www.example.com/moodle/courses/view.php?id=2

How could I use your solution with a link like this? Is it possible?

Thank you very much again.

Wonton

In reply to Wonton Sopabuena

Re: Choosing language from another website

by David Mudrák -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers Picture of Plugins guardians Picture of Testers Picture of Translators
No problem - you just have to put the "lang" parameter like this:

http://www.example.com/moodle/courses/view.php?id=2&lang=es

Please note the ampersand symbol in front of the param name. You might want to google some info about passing URL parameters for further explanation.
In reply to David Mudrák

Re: Choosing language from another website

by Wonton Sopabuena -

¡¡¡PERFECT!!! You are the best David ;-D.

I was looking for link tags like hreflang or charset, but they didn't work. I didn't realize that I could use parameters in the URL.

Thank you very much again!