ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
4 require_once 'Services/Language/classes/class.ilLanguage.php';
5 require_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  {
42  try
43  {
44  $language = $detector->getIso2LanguageCode();
45  if(in_array($language, $installed_languages))
46  {
47  $detected_language = $language;
48  }
49  }
50  catch(ilLanguageException $e)
51  {
52  $ilLog->write(__METHOD__ . ' ' . $e->getMessage());
53  }
54  }
55 
56  return $detected_language;
57  }
58 }
Class ilLanguageDetectorFactory.
Class for language related exception handling in ILIAS.
Class ilLanguageDetection.
static _getInstalledLanguages()