This question has been answered by m.engel. See the first response.
If(!$modx->getObject('modResource', array("friendlyUrl" => $someFriendlyURL) {
$modx->switchContext("web");
$modx->sendForward($someFriendlyURL);
}
//else just process normaly
if($modx->context->key != 'at') return '';
$resourceId = $modx->findResource($_GET['q'], 'web');
if(!$resourceId) return '';
// Maybe in your case just forward...
$modx->sendForward($resourceId);
// otherwise...
$modx->resource = $modx->request->getResource('id', $resourceId, array('forward' => true));
if ($modx->resource) {
$modx->resource->_fields['context_key'] = $modx->context->key;
$modx->resource->_context_key = $modx->context->key;
$modx->resource->set('context_key', $modx->context->key);
$modx->elementCache = array();
$modx->resourceIdentifier = $modx->resource->get('id');
$modx->resourceMethod = 'id';
$modx->request->prepareResponse();
exit();
}
<?php
$babel = $modx->getService('babel','Babel',$modx->getOption('babel.core_path',null,$modx->getOption('core_path').'components/babel/').'model/babel/',$scriptProperties);
if (!($babel instanceof Babel)) return;
/* be sure babel TV is loaded */
if(!$babel->babelTv) return;
/* get snippet properties */
$resourceId = $modx->resource->get('id');
if(!empty($scriptProperties['input'])) {
$resourceId = intval($modx->getOption('input',$scriptProperties,$resourceId));
}
$contextKey = $modx->context->get('key');
if(!empty($scriptProperties['options'])) {
$contextKey =$modx->getOption('options',$scriptProperties,$contextKey);
}
/* determine id of tranlated resource */
$linkedResources = $babel->getLinkedResources($resourceId);
// published check
if($linkedResources[$contextKey])
return $linkedResources[$contextKey];
if($linkedResources["en"])
return $linkedResources["en"];
if($linkedResources["web"])
return $linkedResources["web"];
return $resourceId;