It would be nice to be able to translate the small text "[ close all ]" below the pmgrowl messages. Stan Lemon (the author of jGrowl, http://www.stanlemon.net) gave me the advice to set:
$.jGrowl.defaults.closerTemplate = '
My text...
';
As a work around until this gets fixed I use the following code in my custom_helper.module.
/**
* Implementation of hook_init().
*/
function tierhalterclub_helper_init() {
if (user_access('read privatemsg')) {
// Add required files
// translate the close all string
drupal_add_js("$.jGrowl.defaults.closerTemplate = '<div>" . t("close all") . "</div>';", 'inline', 'footer');
}
}
AFAIK the module weight of the custom module needs to be greater than the pmgrowl module wight. So I set this in my custom_module.install:
/**
* Implementation of hook_install().
*/
function tierhalterclub_helper_registration_install() {
// weight auf 200 setzen, damit wir die letzten sind, die etwas machen
db_query("UPDATE {system} SET weight = 200 WHERE name = 'tierhalterclub_helper'");
}
Note that there's an equivalent to t() for using translateable strings in JS called Drupal.t()
Note also: I'm not sure if the parameter of drupal_add_js in pmgrowl_init are correctly set. Shouldn't the scope 'footer' be the third parameter.
Comments
Comment #1
berdirCan you create a patch of your changes? See http://drupal.org/patch/create
Comment #2
osopolarInstead of calling drupal_add_js in hook_init the "close all" text will be overwritten in the file pmgrowl.js by adding the following code.
// overwrite the jgrowl "close all" text to enable it for translation
$.jGrowl.defaults.closerTemplate = '
';
Patch attached.
By reviewing this patch please check also this:
I'm not sure if the parameter of drupal_add_js in pmgrowl_init are correctly set. Shouldn't the scope 'footer' be the third parameter.
Comment #3
berdirThanks, will review and test this soon.
Yes, that was wrong and should be fixed now, together with many other things, by my big bugfix patch.
Comment #4
berdirThanks, I've tested and commited your patch.