After applying the attached patch you'll be able to choose a message type. Being 'error', 'warning' or 'status' - as defined by drupal_set_message();

I wanted this because 'error' is kinda heavy to show to a first-time user trying to access pages/functionality. The guy/girl didn't do anything wrong. So I prefer 'warning' even if it still isn't ideal.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

deekayen’s picture

Status: Needs review » Needs work

SInce this touches on it, t() shouldn't wrap variables.

greggles’s picture

t() shouldn't wrap variables.

I believe that requirement is no longer relevant.

greggles’s picture

Issue summary: View changes
Status: Needs work » Needs review
FileSize
1.5 KB

Re-rolled so that it applies to 7.x-1.x-dev.

In spite of what the docs say, I really do think that it's fine to do t($foo) if $foo is some complete string entered by site administrators.

iamEAP’s picture

t($foo) is a no-no. The problem is twofold:

  • It lies to drupal.org's package handling / string translation parsing mechanism. The drupal.org localization infrastructure will think that you need the string "$foo" translated.
  • Despite the above, it may still work in practice (because of how the t() function actually operates). However, as soon as you change the string, all translations will be lost (because the translation is keyed by the string itself); it'll leave the existing translations behind in the localization table as cruft, and you'll have to re-enter text.

To properly translate Drupal variables, you're looking for this kind of thing. Where you're registering your variable with the Variable module and i18n_variable is taking care of things behind the scenes for you (so you can variable_get('your_variable'); and it'll return the localized value for you, without having to run it through anything like t()). Something like this:

/**
 * Implements hook_variable_info().
 */
function r4032login_variable_info() {
  $variables['r4032login_access_denied_message'] = array(
    // Variable definition here, and then also:
    'localize' => TRUE,
  );
  return $variables;
}

Note that this does not create a dependency on Variable, or i18n. It just allows sites that have a need for variable translation to localize your variable (because they would have those modules installed and enabled and know how to use them already).

greggles’s picture

OK, awesome, thanks for the explanation. It seems like that can be a followup in its own issue (indeed it is at #1138562: Integrate with i18n_variable) and we can just go ahead here with #3.

greggles’s picture

#3 still makes sense and still applies.

Any reason not to commit it?

  • Commit ffbc2bd on 7.x-1.x authored by greggles, committed by deekayen:
    Issue #1719342 by greggles, PieterDC: Enable message type selection.
    
deekayen’s picture

Status: Needs review » Patch (to be ported)

8.x got started on this project

deekayen’s picture

Version: 7.x-1.x-dev » 8.x-1.x-dev
bdone’s picture

Assigned: Unassigned » bdone

working on adding this to the 8.x-1.x branch.

  • Commit 4502afd on 8.x-1.x by bdone:
    Issue #1719342 by greggles, PieterDC, bdone: Enable message type...
bdone’s picture

Assigned: bdone » Unassigned
Status: Patch (to be ported) » Fixed

Status: Fixed » Closed (fixed)

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