ILIAS  release_8 Revision v8.23
ilLanguageDetection Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Collaboration diagram for ilLanguageDetection:

Public Member Functions

 __construct ()
 
 detect ()
 Return detected language. More...
 

Protected Attributes

ilLanguageDetectorFactory $factory
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Class ilLanguageDetection

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de /

Definition at line 30 of file class.ilLanguageDetection.php.

Constructor & Destructor Documentation

◆ __construct()

ilLanguageDetection::__construct ( )

Definition at line 34 of file class.ilLanguageDetection.php.

35  {
36  $this->factory = new ilLanguageDetectorFactory();
37  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Member Function Documentation

◆ detect()

ilLanguageDetection::detect ( )

Return detected language.

Definition at line 42 of file class.ilLanguageDetection.php.

References $DIC, Vendor\Package\$e, and ilLanguage\_getInstalledLanguages().

42  : string
43  {
44  global $DIC;
45  $ilLog = $DIC->logger()->lang();
46 
47  $installed_languages = ilLanguage::_getInstalledLanguages();
48  $detected_language = $installed_languages[0];
49 
50  foreach ($this->factory->getValidInstances() as $detector) {
51  try {
52  $language = $detector->getIso2LanguageCode();
53  if (in_array($language, $installed_languages, true)) {
54  $detected_language = $language;
55  }
56  } catch (ilLanguageException $e) {
57  $ilLog->warning($e->getMessage());
58  }
59  }
60 
61  return $detected_language;
62  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
static _getInstalledLanguages()
Get installed languages.
+ Here is the call graph for this function:

Field Documentation

◆ $factory

ilLanguageDetectorFactory ilLanguageDetection::$factory
protected

Definition at line 32 of file class.ilLanguageDetection.php.


The documentation for this class was generated from the following file: