I'd like to have wordpress to do I18N for my javascript. My plan is to have javascript code in php file. For example, one sample.js.php file as below:
function foo()
{
alert(<?php _e('do something'); ?>);
}
The sample.js.php file is referred as javascript.
<script type='text/javascript'>url-to-myplugin/sample.js.php</script>
However, it seems __() and _e() does't work as they are not defined. How to make the _e() and __() work in my case?
Thanks
I found the answer. Below code will do the work.
<?php
define('WP_USE_THEMES', false);
require('./wp-blog-header.php');
?>