ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\GlobalScreen_\UI\Translator Class Reference
+ Collaboration diagram for ILIAS\GlobalScreen_\UI\Translator:

Public Member Functions

 __construct (private readonly Container $dic)
 
 translate (string $identifier, ?string $prefix=null)
 

Data Fields

 $current = (array) ((@include $file) ?? [])
 
if(!isset($current[$key])) else
 
return $translation
 

Package Attributes

function string $translation: string { if ($translation === '-' . $key . '-') { $file = __DIR__ . '/' . self::LANG_PHP
 

Private Attributes

const LANG_PHP = 'lang.php'
 

Detailed Description

Author
Fabian Schmid fabia.nosp@m.n@sr.nosp@m..solu.nosp@m.tion.nosp@m.s

Definition at line 28 of file Translator.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\GlobalScreen_\UI\Translator::__construct ( private readonly Container  $dic)

Definition at line 35 of file Translator.php.

36  {
37  $dic->language()->loadLanguageModule('gsfo');
38  }
$dic
Definition: result.php:31

Member Function Documentation

◆ translate()

ILIAS\GlobalScreen_\UI\Translator::translate ( string  $identifier,
?string  $prefix = null 
)

Definition at line 40 of file Translator.php.

References ILIAS\GlobalScreen_\UI\Translator\$translation, and null.

40  : string
41  {
42  $key = $prefix !== null ? $prefix . '_' . $identifier : $identifier;
43 
44  return $this->dic->language()->txt($key);
45  }
46 
47  private function internal(string $translation): string
48  {
49  if ($translation === '-' . $key . '-') {
50  $file = __DIR__ . '/' . self::LANG_PHP;
51  // touch($file);
52  $current = (array) ((@include $file) ?? []);
53  if (!isset($current[$key])) {
54  $current[$key] = $key;
55  file_put_contents($file, '<?php return ' . var_export($current, true) . ';');
56  } else {
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

Field Documentation

◆ $current

ILIAS\GlobalScreen_\UI\Translator::$current = (array) ((@include $file) ?? [])

Definition at line 52 of file Translator.php.

◆ $translation [1/2]

function string ILIAS\GlobalScreen_\UI\Translator::$translation
package

Definition at line 50 of file Translator.php.

Referenced by ILIAS\GlobalScreen_\UI\Translator\translate().

◆ $translation [2/2]

return ILIAS\GlobalScreen_\UI\Translator::$translation

Definition at line 60 of file Translator.php.

◆ else

if (!isset( $current[ $key])) ILIAS\GlobalScreen_\UI\Translator::else
Initial value:

Definition at line 56 of file Translator.php.

◆ LANG_PHP

const ILIAS\GlobalScreen_\UI\Translator::LANG_PHP = 'lang.php'
private

Definition at line 33 of file Translator.php.


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