API page: http://api.drupal.org/api/drupal/includes--bootstrap.inc/function/get_t/7

Describe the problem you have found:

It seems to me that the distinction between t(), st(), and get_t() needs some clarity. According to get_t(), the only time you need st() is during install.php, for code that you know will never be run at other times. Then the use-case for get_t() seems to be code that might run during install.php, or any other time as well (such as hook_install()). And then of course t() would be code that never runs during install.php.

Is this accurate?

CommentFileSizeAuthor
#7 get_t_1086066.patch2.58 KBmile23
#2 docs_1086066.patch1.1 KBdrewish

Comments

jhodgdon’s picture

Title: Documentation problem with get_t » get_t should describe what it does and why
Issue tags: +Novice

Yes, that's accurate. I agree that get_t() should contain the above information. It also needs to be updated to the doxygen standards. Needs a patch! Good project for a novice doc contributor...

drewish’s picture

Version: 7.x-dev » 8.x-dev
Status: Active » Needs review
StatusFileSize
new1.1 KB
jhodgdon’s picture

Version: 8.x-dev » 7.x-dev
Status: Needs review » Reviewed & tested by the community

Looks good to me! Setting to d7 so the test bot can test it. Should be applied to both 7 and 8.

jhodgdon’s picture

Version: 7.x-dev » 8.x-dev

Needs to go to d8 and then d7

aspilicious’s picture

I needed this information one month ago... *sigh*

mr.baileys’s picture

Status: Reviewed & tested by the community » Needs work

Patch looks great to me, couple of remarks/questions:

  1. +++ b/includes/bootstrap.inc
    @@ -2235,8 +2235,28 @@ function drupal_installation_attempted() {
    + * Return the name of the localization function.
    

    The one-line summary should be third person;

  2. Might be overkill since the one-line summary says all, but should we add a @return block?
  3. Should we add a note to t() to explain the install-time exception and point to the get_t() documentation + add @see get_t() directive?

Setting to needs work for A (sorry, nitpicking…).

Powered by Dreditor.

mile23’s picture

StatusFileSize
new2.58 KB

I'm tempted to try to write one wrapper function for the whole complicated thing. :-)

But instead I'll document it the way I wish it had been when I needed it.

mile23’s picture

Status: Needs work » Needs review
mr.baileys’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, looks good to me.

I'm tempted to try to write one wrapper function for the whole complicated thing. :-)

The single-wrapper approach was considered when get_t() was introduced, but rejected due to the performance impact (#75002-32: Install-time and run-time requirements checking).

dries’s picture

Status: Reviewed & tested by the community » Fixed

Committed to 7.x and 8.x. This was long overdue -- really helpful for newbies. Thanks!

Status: Fixed » Closed (fixed)
Issue tags: -Novice

Automatically closed -- issue fixed for 2 weeks with no activity.