[wp-polyglots] HTML entities in translated strings

Nikolay Bachiyski nbachiyski at developer.bg
Wed Mar 12 14:24:10 GMT 2008


2008/3/12, Peter Westwood <peter.westwood at ftwr.co.uk>:
>
>  On Wed, March 12, 2008 10:19 am, Thomas Henlich wrote:
>  > Hi everyone,
>  >
>  > in order to accomodate for different character encodings in WP, I am
>  > always using HTML entities in translations (e.g. &auml; instead of ä).
>  >
>  > However, I came across some cases where this does not work.
>  >
>  > For example, in wp-includes/script-loader.php:143
>  >
>  > $this->localize( 'post', 'postL10n', array(
>  >       'tagsUsed' =>  __('Tags used on this post:'),
>  >       'add' => attribute_escape(__('Add')),
>  >       'addTag' => attribute_escape(__('Add new tag')),
>  >       'separate' => __('Separate tags with commas'),
>  >       ) );
>  >
>  > the attribute_escape(__('Add')) would become
>  > attribute_escape('Hinzuf&uuml;gen') which would become
>  > 'Hinzuf&amp;uuml;gen'
>  > which is not at all what I intended.

No, attribute_escape('Hinzuf&uuml;gen') returns 'Hinzuf&uuml;gen'.

>  >
>  > What should I do? Is this a bug in WP, i.e. should the attribute_escape
>  > be removed? Or is HTML simply forbidden in this context?
>
> attribute_escape is used within WordPress where ever anything is going to
>  go into an html attribute to ensure that we produce valid, safe html
>
>  It may be that attribute_escape should be able to cope with not double
>  escaping strings so what you are trying to do would work.

westi, attribute_escape uses wp_specialchars, which doesn't double
encode entities.

Happy hackslating,
Nikolay.


More information about the wp-polyglots mailing list