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.
API page: http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/t/7
I think it would be a good idea to mention that t() expects a string written in English as soon as possible, maybe even on the first line. This could help a little to prevent Drupal starters doing something that we've just found in a random (custom) module:
print t('Bonjour');
Comment | File | Size | Author |
---|---|---|---|
#7 | 1265294-doc-t.patch | 1.29 KB | sven.lauer |
Comments
Comment #1
tstoecklerHmm...
Comment #2
scorchio CreditAttribution: scorchio commentedYeah, I know. This is minor than minor, but still, you can't see this info without scrolling. I hope you see my point here (= allowing "first-time users" to get the grasp of the function as soon as possible).
Comment #3
jhodgdonThe @param is normally the correct place to mention specifics of a parameter...
That said, if you can fit this into the one-line description, something like
Translates a string from English to ...
in less than 80 characters, I'd say go for it.
Otherwise, if it doesn't fit in 80 characters, I'm afraid it's a "won't fix". Thoughts?
Comment #4
sven.lauer CreditAttribution: sven.lauer commentedI think a good way to do this would be in the opening paragraph. Something like (added sentence in bold):
Putting this in the initial one-line description makes it easy to overlook it, and does not give a rationale. Having it in the first paragraph means we can be more explicit, it would still be visible without scrolling, and people would see it when they try to figure out what t() does.
Comment #5
jhodgdonI have no objection to this idea. But it should say "This text" instead of "These texts". Text (I think) is not a countable noun in English.
Comment #6
scorchio CreditAttribution: scorchio commentedMy initial thought was exactly the same as in #3, but I would welcome any improvement on this :)
Comment #7
sven.lauer CreditAttribution: sven.lauer commented@jhodgdon: I think you are right about "text". Anyhow, I went with "these strings", because it really refers back to the strings stored in the database for translation.
Patch attached. Also applies cleanly to 7.x.
Comment #8
sven.lauer CreditAttribution: sven.lauer commentedComment #9
jhodgdonLooks fine, thanks!
Comment #10
Dries CreditAttribution: Dries commentedCommitted to 8.x. Thanks.
Comment #11
jhodgdonDid this patch not apply to D7? I'll retest...
Comment #12
jhodgdon#7: 1265294-doc-t.patch queued for re-testing.
Comment #13
webchickCommitted and pushed to 7.x. Thanks!