[translations] Use of variables in t()

Fernando P. García fernando at develcuy.com
Tue Dec 23 21:42:23 UTC 2008


Derek,

I'm sure you have a good reason to pass string $variables to t(), instead of
"strings".

What current potx does is to respect(and honor) the Drupal coding
starndards. So the "good practice" is to use t("string") for text
translation.

What I suggest is to create a tin 4 lines alias function:
/**
 * Alias function of t(), use only with variables and constants.
 * For "strings" please use t() instead.
 */
function tr() {
  $args = func_get_args();
  call_user_func_array('t', $args);
}

I enjoy the $tr = t way, but perhaps core might realize about "what if..."
...somebody needs to silently(abot poedit) translate $variables and
CONSTANTS.

Merry Christmas! Feliz Navidad!

On Tue, Dec 23, 2008 at 3:31 PM, Derek Wright <drupal at dwwright.net> wrote:

>
> On Dec 23, 2008, at 6:53 PM, Hans Salvisberg wrote:
>
> > Here's what I do to get potx to shut up:
> >
> > $tr = 't';
> > $tr($foo)
>
> Slick! ;)  Very clever, thanks!
>
> > I forgot why I'm not using $t, but I think there was a reason...
>
> Because potx still sees "$t($foo)" as if it's "t($foo)" and it gives
> the warning, anyway.  By using $tr($foo) it all works.
>
> I guess it's a minor performance hit to do this, and it slightly
> obfuscates the code, so I doubt we can convince core to either
> implement or document this practice...
>
> @Gabor: thoughts? ;)
>
> Thanks,
> -Derek (dww)
>
>
>
> _______________________________________________
> translations mailing list
> translations at drupal.org
> http://lists.drupal.org/mailman/listinfo/translations
>



-- 
Fernando P. García, http://www.develcuy.com
Developer - Analista de Sistemas
+51 1 9 8991 7871, Mz. P Lt. 30 1et Urb. Pachacamac - VES, Lima - Perú
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/translations/attachments/20081223/fd93c837/attachment.htm 


More information about the translations mailing list