Invalid marker content in indexpage.module:272 * format_plural($count,t('There is one !type node.',array('!type'=>$type_name)),t('There are @count !type nodes.',array('!type'=>$type_name)))

I don't see an invalid marker and the t() calls work as expected.

Comments

gábor hojtsy’s picture

Status: Active » Fixed

It is invalid, since format_plural() itself performs the t(), so you should not call t() before format_plural. The rule is that you pass single strings to format_plural() in both the singular and plural parameters. If you need something replaced, you should do it after format_plural() returns back. Otherwise you'd get translated versions of the messages in all languages including all kinds of types appear in the database as 'English' strings to translate. You should instead do:

strtr(
  format_plural(
    $count, 
    'There is one !type node.',
    'There are @count !type nodes.'
  ),
  array('!type' => $type_name)
);

Depending on where you use it, and how $type_name is escaped, I'd also suggest you think about escaping it. This translates the original English strings properly, and only adds the type after the translation is done.

nancydru’s picture

Thank you, Gábor. This is my first time using format_plural, so I guess I just misunderstood it, even with looking at the API.

The type name comes from the node module, so it should be safe. It is not user entered,

gábor hojtsy’s picture

If the $type_name is human readable type name, then it is user entered. Only if it is the machine name (eg. what appears in node/add/typename) If the human readable name is used, you should escape it.

nancydru’s picture

I do a check_plain on it.

gábor hojtsy’s picture

Great!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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