This question has been answered by Bruno17. See the first response.
$lang = $modx->getOption('lang',$scriptProperties,'en');
$langparents = array('en'=>10,'de'=>20);
$parent = $langparents[$lang];
$menuindex = $modx->resource->get('menuindex');
$link_id = $modx->resource->get('id');//link to the current resource, if other resource not found
if ($resource = $modx->getObject('modResource',array('parent'=>$parent,'menuindex'=>$menuindex))){
$link_id = $resource->get('id');
}
return $modx->makeUrl($link_id);<a href="[[makeLangLink? &lang=`de`]]">DE</a>