Drupal Answers is a question and answer site for Drupal developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using coder to review code of my module, and I am seeing this in .module file. I am not sure how to fix this up.

Line 49: The $string argument to t() should not begin or end with a space. (Drupal Docs) [i18n_11]

  '#title' => check_plain(t('Role Limit (' . $value . ')')),
share|improve this question
Are you using Drupal 6? – Randell Mar 20 '14 at 6:06
No, its Drupa 7. – Tanvir Ahmad Mar 20 '14 at 8:04
up vote 1 down vote accepted

It's a bug with coder module.. I can replicate using D7 version... See fix below..

'#title' => t('Role Limit (@value)', array('@value' => $value)),

Root cause analysis of above problem is

Coder works with pattern matching to report errors.. In above code you can see a space before single quote inside t function.. that's the reason it's throwing error...

I see same issue in D7 too... Changing your code as explained above will solve the issue..

share|improve this answer
You should't use variables directly in t() function. – Елин Й. Mar 20 '14 at 6:38
Agree @ Елин Й , Updated my answer :-) – Anil Sagar Mar 20 '14 at 6:54
Thanks @AnilSagar. – Tanvir Ahmad Mar 20 '14 at 7:58

The correct way of using variables in t() function is using placeholders.

Example of a correct usage:

$string = t('Role Limit @value', array('@value' => $value));

There are three types of placeholders for t() function.

  • @variable : The variable will be checked through check_plain() function before it is inserted, so you don't need to check it in your script.
  • !variable : The variable will be inserted as it is.
  • %variable : The variable will be checked through check_plain() and highlighted with drupal_placeholder()
share|improve this answer

The message from the coder module is pretty much nonsense. The text of the error message doesn't really explain the problem.

You cannot pass variables into the t() function like that (check the docs in the link It specifically says that).

The reason is users submitting translations can't possibly know what is in that variable so it cannot be translated.

Also, you don't need to run through check_plain() if you use t() correctly as it will do that for you (check out the different replacement patterns you can use and what they do in the drupal 6 version of the docs for the t() function).

You should do it like this:

'#title' => t('Role Limit (@value)', array('@value' => $value)),
share|improve this answer
Agree, it makes no sense. thanks for the help – Tanvir Ahmad Mar 20 '14 at 7:57

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.