[wp-hackers] internationalization of javascripts

Peter Westwood peter.westwood at ftwr.co.uk
Mon Dec 12 22:11:08 GMT 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nikolay Bachiyski wrote:
> Nikolay Bachiyski wrote:
>> Since javascript files are plain text their internatinalization is
>> harder. Is it possible that all .js files are converted to .php ones?
>>
>> I have made a sample patch for wp-admin/list-manipulation.js,
>> converted to wp-admin/list-manipulation.js.php [].
> 
> The missing link is: http://trac.wordpress.org/ticket/2070
> 
>>
>> There are, of course some issues, especially concerning the caching of
>> those files. I, myself, have not much experience with HTTP's cache
>> directives, but if somebody is proficient in this area, why not put
>> all javascripts, to some extent, under conrtrol?
>>
>> If you all agree, I volunteer to convert all the files needed
>> (fortunately for TinyMCE, these are only the lang files :) ).

I believe some if not all of these functions actual accept the text you
wish to translate as arguments and so we should be able to do the
translation in existing php files and leave the javascript ones as
javascript.

For example:

function deleteSomething( what, id, message ) {
 	what.replace('-', ' ');
- -	if (!message) message = 'Are you sure you want to delete this ' + what
+ '?';
+	if (!message) message = '<?php echo addslashes(__('Are you sure you
want to delete this')); ?>' + ' ' + what + '?';

deleteSomething is always called with a translatable string passed in as
message.

cheers

westi
- --
Peter Westwood
http://blog.ftwr.co.uk
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFDnfV8VPRdzag0AcURAsaYAJ45xTfy4tpAS9Q8zLg/xFydLodHKQCfT7IV
W3nNUgK3yym5R8DLD+a1mXI=
=CqHV
-----END PGP SIGNATURE-----



More information about the wp-hackers mailing list