mikelietz wrote:
> 1. Is there a better way to do that massive _t()?
Yes.
Never, ever, ever put executable code as part of the "text to translate"
parameter of a translation function. Doing so makes it impossible to
translate. Use constant string values ONLY.
A recent change to the translation functions makes it possible to pass
sprintf()-style replacements as an array in the second parameter of the
call to _t() or _e(). Like so:
_t('Please set your username in the <a href="%s">Twitter plugin
config</a>', array(URL::get('admin', 'page=plugins&configure=' .
$this->plugin_id . '&configaction=Configure'). '#plugin_' .
$this->plugin_id), 'twitter' );
The %s is replaced with the value in the array.
If there were two values to be replaced, use %1$s and %2$s. The order
of replaced parameters sometimes changes in other languages, so these
numbers are important to include. The %1$s is replaced with the first
value in the array, %2$s with the second, etc.
The replacements MUST be in an array. It's how the function
differentiates the replacement parameters from the domain.
Don't forget to include a domain with the plugin as the third parameter,
if you're including a replacement array, or the second parameter if
you're not.
Doing things this way will ensure that the text can be translated.
I should mention that this is similar to using sprintf(), which is what
we did prior to these changes:
$foo = sprintf(_t('Replaced text %s times'), '4');
Note that it was previously impossible to use _e() with the sprintf()
replacement strings, since you could not provide parameters to it before
it produced output. The new version of the function works the same as
_t(), described above, and should perform the replacements before
outputting anything.
At least, that's the expected behavior. ;)
> 2. Is there any reason I shouldn't make similar changes to other
> plugins that point out when they're not configured?
If you're doing it like I described above, I think this is a good thing.
Owen
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/habari-dev
-~----------~----~----~----~------~----~------~--~---