ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilLanguageDetection.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
29
30 public function __construct()
31 {
33 }
34
38 public function detect(): string
39 {
40 global $DIC;
41 $ilLog = $DIC->logger()->lang();
42
43 $installed_languages = ilLanguage::_getInstalledLanguages();
44 $detected_language = $installed_languages[0];
45
46 foreach ($this->factory->getValidInstances() as $detector) {
47 try {
48 $language = $detector->getIso2LanguageCode();
49 if (in_array($language, $installed_languages, true)) {
50 $detected_language = $language;
51 }
52 } catch (ilLanguageException $e) {
53 $ilLog->warning($e->getMessage());
54 }
55 }
56
57 return $detected_language;
58 }
59}
factory()
Class ilLanguageDetection.
ilLanguageDetectorFactory $factory
detect()
Return detected language.
Class ilLanguageDetectorFactory.
Class for language related exception handling in ILIAS.
static _getInstalledLanguages()
Get installed languages.
global $DIC
Definition: shib_login.php:26