updated version
(from http://plugins.trac.wordpress.org/changeset/748315/p2p-wpml)