Get link for same page in different language
It should work when using this function: https://api.drupal.org/api/drupal/modules!translation!translation.module/function/translation_node_get_translations/7

This will return all the translations of a given nid, when an ES translation is given you can print your l().