ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilLanguageDetection.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2015 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Language/classes/class.ilLanguage.php';
5require_once 'Services/Language/classes/class.ilLanguageDetectorFactory.php';
6
13{
17 protected $factory;
18
22 public function __construct()
23 {
24 $this->factory = new ilLanguageDetectorFactory();
25 }
26
30 public function detect()
31 {
35 global $ilLog;
36
37 $installed_languages = ilLanguage::_getInstalledLanguages();
38 $detected_language = $installed_languages[0];
39
40 foreach ($this->factory->getValidInstances() as $detector) {
41 try {
42 $language = $detector->getIso2LanguageCode();
43 if (in_array($language, $installed_languages)) {
44 $detected_language = $language;
45 }
46 } catch (ilLanguageException $e) {
47 $ilLog->write(__METHOD__ . ' ' . $e->getMessage());
48 }
49 }
50
51 return $detected_language;
52 }
53}
An exception for terminatinating execution or to throw for unit testing.
Class ilLanguageDetection.
Class ilLanguageDetectorFactory.
Class for language related exception handling in ILIAS.
static _getInstalledLanguages()