ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 27 of file class.ilLanguageDetection.php.

Constructor & Destructor Documentation

◆ __construct()

ilLanguageDetection::__construct ( )

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

32  {
33  $this->factory = new ilLanguageDetectorFactory();
34  }
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 39 of file class.ilLanguageDetection.php.

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

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

Field Documentation

◆ $factory

ilLanguageDetectorFactory ilLanguageDetection::$factory
protected

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


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