JavaScript

Translate your javascript by doing

drupal_add_js(array('my_module' => array('my_string' => t('My string'))), 'setting')

Get translated strings from javascript: Drupal.settings.my_module.mystring
Same with urls:

drupal_add_js(array('my_module' => array('my_url' => url('node/10'))), 'setting') 

It's more reliable and less work than using $base_path and Clean URL setting.

Source: http://www.lullabot.com/audiocast/podcast-50-drupal-tips-and-tricks

Comments

mercmobily’s picture

Hi,

Nice one!
We are changing the JS as we speak.
However, once I know that everything works, I will definitely implement the base_path thing this way!

Thanks,

Merc.

mercmobily’s picture

I don't get it...

Does anybody here know what the lines above actually do?

Merc.

mercmobily’s picture

Status: Active » Closed (won't fix)

Hi,

Sorry, but I am gonna have to close this one...
I spent an hour trying to figure out what on earth those guys meant in the podcast, and... I still don't get it :-/

Please send me a working, functional, explained patch if you want this to happen.
(Please don't forget to justify and explain it).

Bye,

Merc.