[wp-polyglots] Translation Guidelines / HTML Character Entities
Francesc Hervada-Sala
francesc at hervada.org
Mon Sep 17 06:19:25 GMT 2007
Hello Kimmo,
Kimmo Suominen schrieb am 04.09.2007 09:14:
> Use the Character Set Conversions plugin:
>
> http://kimmo.suominen.com/sw/charsets/
>
> It assumes that the original messages are translated in UTF-8, per
> WordPress guidelines, and will convert them to the user-selected
> character set.
a nice plugin! :-)
I have a suggestion. Instead of:
function CharSets()
{
$this->cc = get_settings('blog_charset'); // . '//TRANSLIT';
add_filter('gettext', array(&$this, 'convert_cc'));
}
function convert_cc($text)
{
if (strncasecmp('UTF-8', $this->cc, 5))
return iconv('UTF-8', $this->cc, $text);
return $text;
}
You could write it like so [not tested!]:
function CharSets()
{
$this->cc = get_settings('blog_charset'); // . '//TRANSLIT';
if (strncasecmp('UTF-8', $this->cc, 5))
add_filter('gettext', array(&$this, 'convert_cc'));
}
function convert_cc($text)
{
return iconv('UTF-8', $this->cc, $text);
}
this way, if the blog uses UTF-8 the filter won't be set, instead of
repeatedly calling the function convert_cc which only compares two
strings but does nothing else. (On the other way, if the blog uses UTF-8
one should deactivate the plugin). And if the blog does not use UTF-8,
the call to convert_cc is faster, because it does not need to compare
the two strings each time before converting the text.
Best regards,
Francesc Hervada-Sala
More information about the wp-polyglots
mailing list