Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
In the template file twitter-pull-listing.tpl.php
the "Follow @username" button is translated in this way: t("Follow @$tweet->screenname")
, this creates an entry in the locale_source
for every username, multiply this per every page where this username appears and in an average site you will get several hundred thousand entries in that table.
Proposed resolution
Use the variable injection that comes along with the t()
function: t("Follow !screenname", array('!screenname'=>"@{$tweet->screenname}")
.
Comment | File | Size | Author |
---|---|---|---|
#7 | username_translated-2799465-7.patch | 904 bytes | esolitos |
Comments
Comment #2
esolitosPatch.
Comment #3
joachim CreditAttribution: joachim as a volunteer commentedGood catch!
Though a few problems:
- the placeholder should be @ rather than !. I expect twitter usernames can't have anything nasty in them, but it's best to be safe.
- the replacement value should be a straight variable. No need to quote. And the @ won't do anything here.
- one space each side of the => please.
Comment #4
esolitosI'll fix the patch in the next days before leaving for Dublin. :)
What do you mean? The "@" is there to appear front of the Tw username, I added to to keep it like it was before.
Comment #5
esolitosNew patch with suggestions, I left the "@" in front of the screen name, since it's quite standard when referring to Twitter, and also was used before, so most likely we should not change the output.
Comment #6
joachim CreditAttribution: joachim as a volunteer commented> The "@" is there to appear front of the Tw username, I added to to keep it like it was before.
Ah, of course! Sorry, I was being stupid, I was only thinking of the '@' in the context of Drupal's t() placeholders...
> + <?php print l(t("Follow @screenname", array('@screenname' => '@'.$tweet->screenname)), 'https://twitter.com/' . $tweet->screenname, array('attributes'=> array(
Needs a space each side of the . operator too.
Comment #7
esolitosDamn, why did I change that. :)
I fixed the spacing, new patch should be fine!
(I also fixed another spacing "error" in the file.)