Well, Now I resolve in a way. Joomfish future, the pre version before the realise do not work to me with k2. So I fill table #__js_traslationmap to make realtionship to items in differents languages.
Then I override the method rerouteCurrentUrl in class JFRoute (libraries/joomfish/route/jfroute.php
This is the new code (there is part I am not sure).
public function rerouteCurrentUrl($code=null)
{
$vars = $this->getSafeVariablesFromRoutedRequest();
/* Take care of this if, I am not really sure */
if($vars == 'item' && ($vars==$vars) && $vars = 'com_k2'){
$id = preg_replace("/[^0-9]/","",$vars);
if($vars==$code){
return urldecode(JRoute::_(K2HelperRoute::getItemRoute($vars)));
}else{
/* nl because is my default site language, if you know how to get this value, please tell me */
if($code!='nl' && $vars!='nl'){
$query = "SELECT T.translation_id as k2_id,K.alias as alias FROM #__jf_translationmap T ".
"INNER JOIN #__k2_items K ON (K.id = T.translation_id) ".
"WHERE T.reference_id = (SELECT TM.reference_id FROM #__jf_translationmap TM WHERE TM.translation_id = $id) ".
"AND (SUBSTR(T.LANGUAGE,1,2) = '$code') AND (T.reference_table = 'k2_items') ";
}else if($vars!='nl'){
$query = "SELECT T.reference_id as k2_id,K.alias as alias FROM #__jf_translationmap T ".
"INNER JOIN #__k2_items K ON (K.id = T.reference_id) ".
"WHERE (T.reference_table = 'k2_items') AND (T.translation_id = $id)";
}else{
$query = "SELECT T.translation_id as k2_id,K.alias as alias FROM #__jf_translationmap T ".
"INNER JOIN #__k2_items K ON (K.id = T.translation_id) ".
"WHERE (T.reference_table = 'k2_items') AND (T.reference_id = $id) AND (SUBSTR(T.LANGUAGE,1,2) = '$code')";
}
}
if(!empty($query)){
$db = JFactory::getDBO();
$db->setQuery($query);
$result = $db->loadObject();
if($result){
$url = urldecode(JRoute::_(K2HelperRoute::getItemRoute($result->k2_id.':'.urlencode($result->alias))));
$url = str_ireplace('/'.$vars.'/', '/'.$code.'/', $url);
return $url;
}
}
}
// @Todo if this is not default language this vars might be wrong due to translated path!
$router = JFactory::getApplication()->getRouter();
$uri = JURI::getInstance();
/////// 1. save current lang codes for later ///////////////////////////////////////////
$currentlang = isset($vars) ? $vars : null;
$currentJoomlaLang = $this->_conf->get('language');
/////// 2. set lang code in router and JURI vars to $code, push it to the router
$vars = $code;
$uri->setVar('lang', $code);
$router->setVars($vars, false);
/////// 3. swap menu values with translated ones ////////////////////////////////////////
// switch active translation language
$this->switchJFLanguageShortcode($code, true);
JFactory::$language = null; // reset language instance as JFDatabase->setLanguage uses JFactory::getLanguage()
// get translated menu
$menu = JFactory::getApplication()->getMenu();
$menu->__construct(); // force re-loading of the menu
// fix item routes for this item as routing is based on active menu $item->route
// and translated query doesn't change menu routes
//
not needed as it is done in menu override for all items
/*$itemid = $vars ? $vars : JRequest::getInt('Itemid');
$menuitems = & $menu->getMenu();
$this->fixMenuItemRoutes($menuitems, $itemid);*/
/////// 4. route vars //////////////////////////////////////////////////////////////////
$varstring = 'index.php?'.$uri->buildQuery($vars);
//$varstring = 'index.php?lang=nl&option=com_k2&view=item&id=92';
//$currenturl= $uri->toString(array('path', 'query'));
$absolute = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port'));
$routedurl = $absolute . JRoute::_($varstring, true, $uri->isSSL());
/////// 5. reset everything to the previous state so we don't affect anything //////////
$vars = $currentlang;
$uri->setVar('lang', $currentlang);
$router->setVars($vars, false);
$this->switchJFLanguageShortcode($currentlang, false);
$this->switchJoomlaLanguageLongcode($currentJoomlaLang);
JFactory::$language = null;
$menu->__construct();
// fix url if we are using sef domains
$this->prefixToHost($routedurl);
return $routedurl;
}
P.S. I have problems with captcha in this forum, sometimes it's really dificut, Captcha yes, but easier please.