ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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 {
32 global $DIC;
33 $ilLog = $DIC->logger()->lang();
34
35 $installed_languages = ilLanguage::_getInstalledLanguages();
36 $detected_language = $installed_languages[0];
37
38 foreach ($this->factory->getValidInstances() as $detector) {
39 try {
40 $language = $detector->getIso2LanguageCode();
41 if (in_array($language, $installed_languages)) {
42 $detected_language = $language;
43 }
44 } catch (ilLanguageException $e) {
45 $ilLog->warning($e->getMessage());
46 }
47 }
48
49 return $detected_language;
50 }
51}
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()
$DIC
Definition: xapitoken.php:46