I'm currently trying to translate a text in WordPress. The problem is that I'm trying to translate HTML characters which seems to be converted during the translation but I need them as they are in the JS I'm localizing:
wp_localize_script( 'main-js', 'main_object', array(
'homepage_typed_text' => __( 'Apples & Bananas', 'ewk' )
) );
So in the JS it needs to be Apples & Bananas
and not Apples & Bananas
. When I copy it directly to the JS, everything works but not via the translation. Any ideas why this happens?
Update
I've checked the code and found this little thing here in the localize function:
$l10n[ $key ] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8' );
So this function transforms every entity back to his original sign. Damn. So no idea how to skip this..