I have created this in the past. I do not have the code anymore but here is an idea and little code snippet to get you started.
You can observe 'controller_action_layout_generate_blocks_after'
<frontend>
<events>
<controller_action_layout_generate_blocks_after>
<observers>
<example_alternate>
<type>singleton</type>
<class>Example_Alternate_Model_Observer</class>
<method>createAlternateLinks</method>
</example_alternate>
</observers>
</controller_action_layout_generate_blocks_after>
</events>
</frontend>
Then in your observer method find the relevant rewrite and add the link to head block:
public function createAlternateLinks($observer) {
$headBlock = Mage::app()->getLayout()->getBlock('head');
$helper = Mage::helper('example');
if ($headBlock) {
foreach ($Mage::app()->getStores() as $store) {
//this will be your logic for fetching the urls, I suggest using the current urls or registry ('current_product','current_category') to get the product, category
//and then using rewrites finding the relevant url for other store view
$url = $helper->getAlternateUrl();
//this will be used for hreflang but feel free to omit it or simply use store locale
$area = Mage::helper('your_module')->getArea($store->getId());
// add the alternate link
$headBlock->addLinkRel('alternate"' . ' hreflang="' . $area, $url);
}
}
return $this;
}
Then you can get alternate urls using url rewrite model. For example for product page url you can use this
public function rewrittenProductUrl($productId, $storeId) {
$coreUrl = Mage::getModel('core/url_rewrite');
$idPath = sprintf('product/%d', $productId);
$coreUrl->setStoreId($storeId);
$coreUrl->loadByIdPath($idPath);
return $coreUrl->getRequestPath();
}
So really all you have left to do is stick everything together and create the logic for getAlternateUrl using the registry and url rewrites.
Let me know if something is unclear and needs clarification.