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.

CommentFileSizeAuthor
#2 pmgrowl-661336-2.patch455 bytesosopolar

Comments

berdir’s picture

Can you create a patch of your changes? See http://drupal.org/patch/create

osopolar’s picture

Status: Active » Needs review
StatusFileSize
new455 bytes

Instead 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 = '

' + Drupal.t('close all') + '

';

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.

berdir’s picture

Thanks, will review and test this soon.

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.

Yes, that was wrong and should be fixed now, together with many other things, by my big bugfix patch.

berdir’s picture

Status: Needs review » Fixed

Thanks, I've tested and commited your patch.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.