translateDocument should iterate over entities, not nodes

This should be faster and is simpler.