Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translations: when wrong number of placeholders, error: sprintf() Too few arguments #7546

Closed
dscaravaggi opened this issue Mar 26, 2015 · 8 comments
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.
Milestone

Comments

@dscaravaggi
Copy link

Hi all,

may you verify sprintf argument usage at:

core/DataTable/Filter/BeautifyTimeRangeLabels.php line 115

   {
if ($lowerBound < 60) {
return sprintf($this->labelSecondsPlural, $lowerBound);
} else {
// since we're using minutes, we use floor so 1801s+ will be 30m+ and not 31m+
return sprintf($this->labelPlural, "" . floor($lowerBound / 60) . urlencode('+'));
}
}

Thanks a lot
Diego

@mnapoli
Copy link
Contributor

mnapoli commented Mar 26, 2015

Hi Diego, what is the problem here?

@dscaravaggi
Copy link
Author

labelSecondsPlural sprintf format mask is expected to contain only 1 argument, but I noticed that in some cases "%s %s" generate a warning which is logged into piwik.log file:

Warning: sprintf() [function.sprintf]: Too few arguments in...

@mattab
Copy link
Member

mattab commented Apr 8, 2015

maybe this is caused by some translations having the wrong number of placeholders in the translation strings? we should have a test that checks and notices when a translation has invalid number of placeholders.

(fyi @sgiehl maybe transifex has a mechanism to enforce placeholder count to be the same as in english strings? if not, we continue to remove translations that have wrong number of %s)

@mattab mattab added the Bug For errors / faults / flaws / inconsistencies etc. label Apr 8, 2015
@mattab mattab added this to the Short term milestone Apr 8, 2015
@sgiehl
Copy link
Member

sgiehl commented Apr 8, 2015 via email

@mattab mattab changed the title verify sprintf usage at line 115 file core/DataTable/Filter/BeautifyTimeRangeLabels.php Translations: when wrong number of placeholders, error: sprintf() Too few arguments Apr 9, 2015
@mattab
Copy link
Member

mattab commented Apr 9, 2015

nice to hear! let's try to ensure that all translations when they make it into Piwik git repo, use the same number of placeholders as in the english translation, in our transifex migration (#7567)

this should therefore solve this issue in the future so i'm decreasing priority

@mattab mattab modified the milestones: Mid term, Short term Apr 9, 2015
@sgiehl
Copy link
Member

sgiehl commented Apr 12, 2015

we have tests for translation files also checking for the correct parameter count. But they are only marked as "skipped" when failing, so we will not get notice about that.
But updating the translation files using the console command should remove those invalid translations

@dscaravaggi
Copy link
Author

Thanks for your comments,
I understand that this is a secondary issue that could be ignored.

@sgiehl
Copy link
Member

sgiehl commented Jun 22, 2015

I've rechecked that issue. As long as we ALWAYS run a translation update before building a release, this issue should not appear in any release as an update will filter such translations. Btw. tests will fail aswell if the parameter count for any translation does not match, so I'll close this ticket as we can't do much more to prevent such errors in the furure.

@sgiehl sgiehl closed this as completed Jun 22, 2015
@mattab mattab added the answered For when a question was asked and we referred to forum or answered it. label Jun 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answered For when a question was asked and we referred to forum or answered it. Bug For errors / faults / flaws / inconsistencies etc.
Projects
None yet
Development

No branches or pull requests

4 participants