protected function detect($uri=NULL) {
		$this->current=$this->primary;
		if (preg_match('/^'.preg_quote($this->f3->get('BASE'),'/').'\/([^\/?]+)([\/?]|$)/',$uri?:$_SERVER['REQUEST_URI'],$m) &&
				array_key_exists($m[1],$this->languages))
			$this->current=$m[1];
		else {//auto-detect language
			$this->auto=TRUE;
			$detected=array_intersect(explode(',',$this->f3->get('LANGUAGE')),explode(',',implode(',',$this->languages)));
			if ($detected=reset($detected))
				foreach($this->languages as $lang=>$locales)
					if (in_array($detected,explode(',',$locales))) {
						$this->current=$lang;
						break;
					}
		}
		$this->f3->set('LANGUAGE',$this->languages[$this->current]);
	}