ILIAS  trunk Revision v11.0_alpha-1749-g1a06bdef097
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilLanguageDetection Class Reference

Class ilLanguageDetection. More...

+ Collaboration diagram for ilLanguageDetection:

Public Member Functions

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

Protected Attributes

ilLanguageDetectorFactory $factory
 

Detailed Description

Class ilLanguageDetection.

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

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

Constructor & Destructor Documentation

◆ __construct()

ilLanguageDetection::__construct ( )

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

References factory().

31  {
32  $this->factory = new ilLanguageDetectorFactory();
33  }
Class ilLanguageDetectorFactory.
factory()
+ Here is the call graph for this function:

Member Function Documentation

◆ detect()

ilLanguageDetection::detect ( )

Return detected language.

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

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

38  : 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  }
factory()
Class for language related exception handling in ILIAS.
global $DIC
Definition: shib_login.php:22
static _getInstalledLanguages()
Get installed languages.
+ Here is the call graph for this function:

Field Documentation

◆ $factory

ilLanguageDetectorFactory ilLanguageDetection::$factory
protected

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


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