Shape 5

Joomla Templates => Luxon - Club => : lcmp February 06, 2017, 09:16:12 AM



: S5 Quick Contact - Display the Calendar in a different Language
: lcmp February 06, 2017, 09:16:12 AM
I am not a programmer but I know my way around Joomla and PHP enough to have found a solution to display the calendars in quick contact in at least 2 different languages.

It may help somebody in the future who?s looking to display the calendars in different languages.

Take note. This simple solution will allow the user to select a date on the calendar in their native language but, when a selection is made, the post to the form will revert to English. But at least you allowed you user to make the selection in their native language.


You will need to modify the following files:

joomla_root/modules/mod_s5_quick_contact/tmpl/default.php

joomla_root/modules/mod_s5_quick_contact/s5_quick_contact/pikaday.js


1. First make a copy / backup of these 2 files just in case something goes wrong.

2. Make 2 more copies of the pikaday.js file and leave them in the same folder along with the original.

Rename 1 copy of this file to:


pikaday_en.js


( for english )

Rename the other copy of the file to:


pikaday_es.js

( I needed the calendar in spanish hence the: _es in the file name. You can rename your files to whatever you wish but adding the lang specific prefix helps to keep everything in order.  eg, for french you coud rename to pikladay_fr.js )

3. Now open your:

pikaday_es.js

Go to line 241. it reads:

i18n: {

Below this line you will see the words to be translated.

i.e:


previousMonth : 'Previous Month',


For spanish you would change this line to


previousMonth : 'Mes Anterior',

Translate all the days, months, abbreviations etc. to the desired language.

Save the file and close.

4. Now go to:

joomla_root/modules/mod_s5_quick_contact/tmpl/

and open:

default.php

remember to make a backup of this file as well just in case you make a mistake when you alter the original code.


Go to line 195. it reads like this:


:

$doc->addCustomTag('<script src="'.$s5_qc_url.'s5_quick_contact/pikaday.js" type="text/javascript"></script>');



Replace that line with:


:

$lang = JFactory::getLanguage();
if ($lang->getTag() == 'en-GB') {
  $doc->addCustomTag('<script src="'.$s5_qc_url.'s5_quick_contact/pikaday_en.js" type="text/javascript"></script>');
}

$lang = JFactory::getLanguage();
if ($lang->getTag() == 'es-ES') {
  $doc->addCustomTag('<script src="'.$s5_qc_url.'s5_quick_contact/pikaday_es.js" type="text/javascript"></script>');
}



The first string of code defines what js file to look for when the site language is English.

The second string of code defines what js file to look for when the site language is Spanish. Replace the variables in the second string of code to your specific language and remember to replace the file names to whatever names you used in step 2.

Clear your browser cache, reload your site and you should have the calendar displaying different languages automatically depending on the user selected language.

I repeat:

This is a simple / humble solution to let the user be able to make a selection from the calendar in their native language. After the user makes the selection, the calendar posts the calendar selection to the form in English.

I?m not a programmer so please don?t ask me for custom PHP code. I played around with the code and googled a little bit for joomla specific language code and was lucky enough to get it to work.
enjoy,





: Re: S5 Quick Contact - Display the Calendar in a different Language
: mikek February 07, 2017, 08:02:19 AM
Great! Thanks for posting this, I'm sure others will find it helpful!


: Re: S5 Quick Contact - Display the Calendar in a different Language
: jeisson222 June 26, 2017, 09:25:15 PM
Hola gracias por el aporte, hice lo que dices pero cuando se hace la seleccion del la fecha en mi caso la traduccion a espa?ol, la fecha seleccionada queda en ingles y no logro encontrar la traduccion.
http://hoteltierradeoro.com/web/index.php/habitaciones


: Re: S5 Quick Contact - Display the Calendar in a different Language
: mikek June 27, 2017, 07:17:39 AM
Hello,

Please post your questions in English.


: Re: S5 Quick Contact - Display the Calendar in a different Language
: jeisson222 June 27, 2017, 08:41:04 PM
I leave an image


: Re: S5 Quick Contact - Display the Calendar in a different Language
: mikek June 28, 2017, 07:26:37 AM
Hello,

That is controlled by default javascript functions, and not something the module can control very well. There are some instructions here for modifying it so that it shows just numbers and no text. Anything beyond that though is not possible with the current script.

https://www.shape5.com/component/option,com_smf/Itemid,75/topic,42553.0/