ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
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 32 of file Translator.php.

33  {
34  $dic->language()->loadLanguageModule('gsfo');
35  }
$dic
Definition: ltiresult.php:33

Member Function Documentation

◆ translate()

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

Definition at line 37 of file Translator.php.

References ILIAS\GlobalScreen_\UI\Translator\$translation.

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

Field Documentation

◆ $current

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

Definition at line 49 of file Translator.php.

◆ $translation [1/2]

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

Definition at line 47 of file Translator.php.

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

◆ $translation [2/2]

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

Definition at line 57 of file Translator.php.

◆ else

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

Definition at line 53 of file Translator.php.

◆ LANG_PHP

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

Definition at line 30 of file Translator.php.


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