Page MenuHomePhabricator

Translate extension should warn translators about common printf formatting errors
Closed, ResolvedPublic

Description

It's not uncommon for translators to accidentally drop some printf-style formatting characters from strings, particularly things like ordered parameters:

en "1$s's status on 2$s"

ja "%2$s における %1$ のステータス"

Here, the 's' string specifier got dropped by mistake. This should be fairly easy to detect: make sure we have the same number of params and that we're not missing any explicitly-numbered ones. We could highlight the suspicious parts and prompt the translator to correct it or accept anyway.

Since this particular check is applicable only to programs using printf-style formatting from their strings, it could perhaps be applied only when using gettext (which usually is paired with lots of sprintf fun)


Version: unspecified
Severity: enhancement

Details

Reference
bz24064

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 10:59 PM
bzimport set Reference to bz24064.

I'm not familiar with positional formatting characters. What is the meaning of each letter in %2$s for example? Can there be something else in their place or in addition to?

%2%s is the second parameter for a message; it's similar to $2 in MediaWiki messages. %2$s can be replaced by %s only. There's also %[n$]d for integers. Basically the gettext products need a Checker for this parameter type.