How to debug vsprintf() "Too few arguments" error in my log files?

As the other answer already stated, this is probably caused by too few arguments in a call to a translator method.

You have more %d or %s placeholders in the translations string then arguments passed additional to the string.

You should create a copy of app/code/core/Mage/Core/Model/Translate.php in app/code/local/Mage/Core/Model/Translate.php and add a temporary debug call there in the translate() method just above the vsprintf($translated, $args) call.

You could add something like this:

if (substr_count($translated, '%') != count($args)) {
    Mage::log(
        __METHOD__ . '() possible argument count mismatch! '
        . 'Backtrace: ' . mageDebugBacktrace(true, false, true)
    );
}

Logs will be written to var/log/system.log when logging is enabled (and the log file is still the default system.log).

It's a simple check, so it would also appear when you have a translate string containing an escaped percentage character, like "You get 5%% discount!"

You should not edit the core file directly, but if you do then please do not forget to revert this core file to it's original state afterwards! Or else Ben Marks will be mad!


Hard to say without seeing the offending code, but I think you may have a translation call with insufficient number of parameters, something like:

echo $this->__('There are %d things in %s places', $arg);

Check your code for that.