Changing the easyAppointments language by passing a variable to the url

1,027 views
Skip to first unread message

Lucan Baldacchino

unread,
Apr 7, 2016, 11:59:54 AM4/7/16
to Easy!Appointments - Support Group
Can anyone think of a simple way to change the language easyAppointments is shown in by passing in a different URL (or a variable to the URL)?
So for example, when a user is redirected to easyAppointments from a Spanish version of the base site (through link A), easyAppointments is shown in Spanish whereas if they come from an English version of the base site (through alternative link B) , easyAppointments is shown in English.

Thanks!

Lucan Baldacchino

unread,
Apr 7, 2016, 12:31:22 PM4/7/16
to Easy!Appointments - Support Group
For anyone interested in doing this (and taking into account that I am not by any means a PHP coder), I finally hacked a solution that seems to work without breaking anything.

Editing the index.php to accept a parameter via GET which basically switches between one version of the config.php or another depending on the language parameter being passed.

So replacing the line in the index.php: 

require_once __DIR__ . '/config.php';

with the code:

$lang=$_GET['language'];
if($lang && file_exists(__DIR__ . '/config-'.$lang.'.php')) require_once __DIR__ . '/config-'.$lang.'.php';
else require_once __DIR__ . '/config.php';


then duplicating the config.php and renaming it to config-whateverlanguageyouwant.php (in my case config-spanish.php)
and finally changing the line in the new config file from:

const LANGUAGE = 'english';

to reflect whatever the alternative language is. So in my case:

const LANGUAGE = 'spanish';

So now mysite.com/easyappointments/index.php?language=spanish loads the spanish config file, otherwise it loads the default config file (which is english)


Lucan Baldacchino

unread,
Apr 7, 2016, 1:01:51 PM4/7/16
to Easy!Appointments - Support Group
There's nothing like posting a solution for it to stop working... :)
So scrap that solution - it must have been a fluke that it worked even a few times...

Anyone got any other ideas as to how to do this?

abiuniw...@gmail.com

unread,
Aug 27, 2016, 7:15:49 AM8/27/16
to Easy!Appointments - Support Group
Hi Lucan,

I also needed these feature, and made it work by adding the following code to "application" > "controllers" > "appointments.php" file in function "public function __construct()" (line 23) before the line " // Set user's selected language." 

It grabs the given language from GET and put it into the userdata language. The rest will do the appointments controller it self. 

 if (isset($_GET['language'])) {
   $lang
= $_GET['language'];
   $this
->session->set_userdata('language', $lang);
 
}

By calling ../index.php?language=german you can now change the language of the booking front-end. As language you can choose any available in E!A. 


Have a great weekend!

Lucan Baldacchino

unread,
Aug 27, 2016, 8:50:30 AM8/27/16
to Easy!Appointments - Support Group
Thanks very much for that solution! Great! Have a good weekend too!

Adrp

unread,
Jan 28, 2021, 12:43:14 PM1/28/21
to Easy!Appointments - Support Group
Hi, it would be very nice, if someone can advise how to attain this (switching language through URL) for the current version!
Reply all
Reply to author
Forward
0 new messages