ILIAS  trunk Revision v11.0_alpha-1866-gfa368f7776e
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSetupLanguage Class Reference

language handling for setup More...

+ Inheritance diagram for ilSetupLanguage:
+ Collaboration diagram for ilSetupLanguage:

Public Member Functions

 __construct (string $a_lang_key)
 
 txt (string $a_topic, string $a_default_lang_fallback_mod='')
 gets the text for a given topic More...
 
 installLanguages (array $a_lang_keys, array $a_local_keys)
 install languages More...
 
 getInstalledLanguages ()
 get already installed languages (in db) More...
 
 getInstalledLocalLanguages ()
 get already installed local languages (in db) More...
 
 getLocalChanges (string $a_lang_key, string $a_min_date="", string $a_max_date="")
 get locally changed language entries $a_lang_key language key $a_min_date minimum change date "yyyy-mm-dd hh:mm:ss" $a_max_date maximum change date "yyyy-mm-dd hh:mm:ss" Returned value [module][identifier] => value More...
 
 getLocalLanguages ()
 Searches for the existence of *.lang.local files. More...
 
 getInstallableLanguages ()
 Return installable languages. More...
 
 setDbHandler (ilDBInterface $a_db_handler)
 set db handler object object db handler Return true on success More...
 
 loadLanguageModule (string $a_module)
 
- Public Member Functions inherited from ilLanguage
 __construct (string $a_lang_key)
 Constructor read the single-language file and put this in an array text. More...
 
 getLangKey ()
 Return lang key. More...
 
 getDefaultLanguage ()
 Return default language. More...
 
 getTextDirection ()
 Return text direction. More...
 
 getContentLanguage ()
 Return content language. More...
 
 txtlng (string $a_module, string $a_topic, string $a_language)
 gets the text for a given topic in a given language if the topic is not in the list, the topic itself with "-" will be returned More...
 
 txt (string $a_topic, string $a_default_lang_fallback_mod="")
 gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be returned More...
 
 exists (string $a_topic)
 Check if language entry exists. More...
 
 loadLanguageModule (string $a_module)
 Load language module. More...
 
 getInstalledLanguages ()
 Get installed languages. More...
 
 getUsedTopics ()
 Return used topics. More...
 
 getUsedModules ()
 Return used modules. More...
 
 getUserLanguage ()
 Return language of user. More...
 
 getCustomLangPath ()
 
 toJS ($a_lang_key, ?ilGlobalTemplateInterface $a_tpl=null)
 Transfer text to Javascript. More...
 
 toJSMap (array $a_map, ?ilGlobalTemplateInterface $a_tpl=null)
 Transfer text to Javascript. More...
 
 __destruct ()
 destructor saves all language usages to db if log is enabled and ilDB exists More...
 
- Public Member Functions inherited from ILIAS\Language\Language
 toJS ($key)
 

Static Public Member Functions

static _deleteLangData (string $a_lang_key, bool $a_keep_local_change)
 Delete languge data. More...
 
- Static Public Member Functions inherited from ilLanguage
static _getInstalledLanguages ()
 Get installed languages. More...
 
static _lookupEntry (string $a_lang_key, string $a_mod, string $a_id)
 
static lookupId (string $a_lang_key)
 Lookup obj_id of language. More...
 
static getFallbackInstance ()
 Builds a global default language instance. More...
 
static getGlobalInstance ()
 Builds the global language object. More...
 

Data Fields

array $text
 
string $lang_default = "en"
 
string $lang_path
 
string $lang_key
 
string $separator = "#:#"
 
string $comment_separator = "###"
 
- Data Fields inherited from ilLanguage
ILIAS $ilias
 
array $text = []
 
string $lang_default
 
string $lang_user
 
string $lang_path
 
string $lang_key
 
string $lang_name
 
string $separator = "#:#"
 
string $comment_separator = "###"
 
array $loaded_modules = array()
 

Protected Member Functions

 getAvailableLanguages ()
 get already registered languages (in db) More...
 
 checkLanguage (string $a_lang_key, string $scope="")
 validate the logical structure of a lang-file More...
 
 cut_header (array $content)
 Remove *.lang header information from '$content'. More...
 
 flushLanguage (string $a_lang_key, string $a_mode="all")
 remove language data from database $a_lang_key language key $a_mode "all" or "keep_local" More...
 
 insertLanguage (string $lang_key, string $scope="")
 insert language data from file in database More...
 

Protected Attributes

ilDBInterface $db
 
- Protected Attributes inherited from ilLanguage
array $cached_modules = array()
 
array $map_modules_txt = array()
 
bool $usage_log_enabled = false
 
string $cust_lang_path
 
ilLogger $log
 
ilCachedLanguage $global_cache
 

Additional Inherited Members

- Static Protected Member Functions inherited from ilLanguage
static logUsage (string $a_module, string $a_identifier)
 saves tupel of language module and identifier More...
 
static isUsageLogEnabled ()
 checks if language usage log is enabled you need MySQL to use this function this function is automatically enabled if DEVMODE is on this function is also enabled if language_log is 1 More...
 
- Static Protected Attributes inherited from ilLanguage
static array $used_topics = array()
 
static array $used_modules = array()
 
static array $lng_log = array()
 

Detailed Description

language handling for setup

this class offers the language handling for an application. the constructor is called with a small language abbreviation e.g. $lng = new Language("en"); the constructor reads the single-languagefile en.lang and puts this into an array. with e.g. $lng->txt("user_updated"); you can translate a lang-topic into the actual language

Author
Peter Gabriel pgabr.nosp@m.iel@.nosp@m.datab.nosp@m.ay.d.nosp@m.e
Version
$Id$
Todo:

The DATE field is not set correctly on changes of a language (update, install, your stable). The format functions do not belong in class.Language. Those are also applicable elsewhere. Therefore, they would be better placed in class.Format

This somehow needs to be reconciled with the base class and most probably be factored into two classes, one for management, one for retrieval.

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

Constructor & Destructor Documentation

◆ __construct()

ilSetupLanguage::__construct ( string  $a_lang_key)

Definition at line 52 of file class.ilSetupLanguage.php.

References $lang_default.

53  {
54  $this->lang_key = $a_lang_key ?: $this->lang_default;
55  $il_absolute_path = realpath(__DIR__ . "/../../../../../");
56  $this->lang_path = $il_absolute_path . "/lang";
57  $this->cust_lang_path = $il_absolute_path . "/lang/customizing";
58  }

Member Function Documentation

◆ _deleteLangData()

static ilSetupLanguage::_deleteLangData ( string  $a_lang_key,
bool  $a_keep_local_change 
)
static

Delete languge data.

$a_lang_key lang key

Definition at line 357 of file class.ilSetupLanguage.php.

References $ilDB.

357  : void
358  {
359  global $ilDB;
360 
361  if (!$a_keep_local_change) {
362  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
363  $ilDB->quote($a_lang_key, "text"));
364  } else {
365  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
366  $ilDB->quote($a_lang_key, "text") .
367  " AND local_change IS NULL");
368  }
369  }

◆ checkLanguage()

ilSetupLanguage::checkLanguage ( string  $a_lang_key,
string  $scope = "" 
)
protected

validate the logical structure of a lang-file

This function checks if a lang-file of a given lang_key exists, the file has a header, and each lang-entry consists of exactly three elements (module, identifier, value).

$a_lang_key international language key (2 digits) $scope empty (global) or "local" $info_text message about results of check OR "1" if all checks successfully passed

Definition at line 264 of file class.ilSetupLanguage.php.

References ilLanguage\$cust_lang_path, $lang_path, $path, $scope, and cut_header().

Referenced by installLanguages().

264  : bool
265  {
266  $scopeExtension = "";
267  if (!empty($scope)) {
268  if ($scope === "global") {
269  $scope = "";
270  } else {
271  $scopeExtension = "." . $scope;
272  }
273  }
274 
276  if ($scope === "local") {
278  }
279 
280  $tmpPath = getcwd();
281  chdir($path);
282 
283  // compute lang-file name format
284  $lang_file = "ilias_" . $a_lang_key . ".lang" . $scopeExtension;
285 
286  // file check
287  if (!is_file($lang_file)) {
288  chdir($tmpPath);
289  return false;
290  }
291 
292  // header check
293  if (!$content = $this->cut_header(file($lang_file))) {
294  chdir($tmpPath);
295  return false;
296  }
297 
298  // check (counting) elements of each lang-entry
299  foreach ($content as $key => $val) {
300  $separated = explode($this->separator, trim($val));
301  $num = count($separated);
302 
303  if ($num !== 3) {
304  chdir($tmpPath);
305  return false;
306  }
307  }
308 
309  chdir($tmpPath);
310 
311  // no error occured
312  return true;
313  }
$scope
Definition: ltiregstart.php:47
$path
Definition: ltiservices.php:29
cut_header(array $content)
Remove *.lang header information from '$content'.
string $cust_lang_path
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cut_header()

ilSetupLanguage::cut_header ( array  $content)
protected

Remove *.lang header information from '$content'.

This function seeks for a special keyword where the language information starts. If found it returns the plain language information; otherwise returns false.

$content expect an ILIAS lang-file

Returns
bool|string[]

Definition at line 325 of file class.ilSetupLanguage.php.

Referenced by checkLanguage(), and insertLanguage().

326  {
327  foreach ($content as $key => $val) {
328  if (trim($val) === "<!-- language file start -->") {
329  return array_slice($content, $key + 1);
330  }
331  }
332  return false;
333  }
+ Here is the caller graph for this function:

◆ flushLanguage()

ilSetupLanguage::flushLanguage ( string  $a_lang_key,
string  $a_mode = "all" 
)
protected

remove language data from database $a_lang_key language key $a_mode "all" or "keep_local"

Definition at line 340 of file class.ilSetupLanguage.php.

References $ilDB.

Referenced by installLanguages().

340  : void
341  {
342  global $ilDB;
343 
344  self::_deleteLangData($a_lang_key, ($a_mode === "keep_local"));
345 
346  if ($a_mode === "all") {
347  $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = " .
348  $ilDB->quote($a_lang_key, "text"));
349  }
350  }
+ Here is the caller graph for this function:

◆ getAvailableLanguages()

ilSetupLanguage::getAvailableLanguages ( )
protected

get already registered languages (in db)

Definition at line 235 of file class.ilSetupLanguage.php.

References $ilDB, and $r.

Referenced by installLanguages().

235  : array
236  {
237  global $ilDB;
238 
239  $arr = array();
240 
241  $query = "SELECT * FROM object_data " .
242  "WHERE type = " . $ilDB->quote("lng", "text");
243  $r = $ilDB->query($query);
244 
245  while ($row = $ilDB->fetchObject($r)) {
246  $arr[$row->title]["obj_id"] = $row->obj_id;
247  $arr[$row->title]["status"] = $row->description;
248  }
249 
250  return $arr;
251  }
$r
+ Here is the caller graph for this function:

◆ getInstallableLanguages()

ilSetupLanguage::getInstallableLanguages ( )

Return installable languages.

Definition at line 580 of file class.ilSetupLanguage.php.

References Vendor\Package\$d, and $lang_key.

580  : array
581  {
582  $d = dir($this->lang_path);
583  $tmpPath = getcwd();
584  chdir($this->lang_path);
585 
586  $installableLanguages = [];
587  // get available lang-files
588  while ($entry = $d->read()) {
589  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry))) {
590  $lang_key = substr($entry, 6, 2);
591  $installableLanguages[] = $lang_key;
592  }
593  }
594 
595  chdir($tmpPath);
596 
597  return $installableLanguages;
598  }

◆ getInstalledLanguages()

ilSetupLanguage::getInstalledLanguages ( )

get already installed languages (in db)

Definition at line 193 of file class.ilSetupLanguage.php.

References $ilDB, and $r.

193  : array
194  {
195  global $ilDB;
196 
197  $arr = [];
198  if ($ilDB instanceof ilDBInterface) {
199  $query = "SELECT * FROM object_data " .
200  "WHERE type = " . $ilDB->quote("lng", "text") . " " .
201  "AND " . $ilDB->like("description", "text", "installed%");
202  $r = $ilDB->query($query);
203 
204  while ($row = $ilDB->fetchObject($r)) {
205  $arr[] = $row->title;
206  }
207  }
208  return $arr;
209  }
$r

◆ getInstalledLocalLanguages()

ilSetupLanguage::getInstalledLocalLanguages ( )

get already installed local languages (in db)

Definition at line 214 of file class.ilSetupLanguage.php.

References $ilDB, and $r.

214  : array
215  {
216  global $ilDB;
217 
218  $arr = [];
219  if ($ilDB instanceof ilDBInterface) {
220  $query = "SELECT * FROM object_data " .
221  "WHERE type = " . $ilDB->quote("lng", "text") . " " .
222  "AND description = " . $ilDB->quote("installed_local", "text");
223  $r = $ilDB->query($query);
224 
225  while ($row = $ilDB->fetchObject($r)) {
226  $arr[] = $row->title;
227  }
228  }
229  return $arr;
230  }
$r

◆ getLocalChanges()

ilSetupLanguage::getLocalChanges ( string  $a_lang_key,
string  $a_min_date = "",
string  $a_max_date = "" 
)

get locally changed language entries $a_lang_key language key $a_min_date minimum change date "yyyy-mm-dd hh:mm:ss" $a_max_date maximum change date "yyyy-mm-dd hh:mm:ss" Returned value [module][identifier] => value

Definition at line 378 of file class.ilSetupLanguage.php.

References $ilDB, $q, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by insertLanguage().

378  : array
379  {
380  global $ilDB;
381 
382  if ($a_min_date === "") {
383  $a_min_date = "1980-01-01 00:00:00";
384  }
385  if ($a_max_date === "") {
386  $a_max_date = "2200-01-01 00:00:00";
387  }
388 
389  $q = sprintf(
390  "SELECT * FROM lng_data WHERE lang_key = %s " .
391  "AND local_change >= %s AND local_change <= %s",
392  $ilDB->quote($a_lang_key, "text"),
393  $ilDB->quote($a_min_date, "timestamp"),
394  $ilDB->quote($a_max_date, "timestamp")
395  );
396  $result = $ilDB->query($q);
397 
398  $changes = array();
399  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
400  $changes[$row["module"]][$row["identifier"]] = $row["value"];
401  }
402  return $changes;
403  }
$q
Definition: shib_logout.php:21
+ Here is the caller graph for this function:

◆ getLocalLanguages()

ilSetupLanguage::getLocalLanguages ( )

Searches for the existence of *.lang.local files.

Returns array with language keys

Definition at line 555 of file class.ilSetupLanguage.php.

References Vendor\Package\$d, and $lang_key.

555  : array
556  {
557  $local_langs = array();
558  if (is_dir($this->cust_lang_path)) {
559  $d = dir($this->cust_lang_path);
560  $tmpPath = getcwd();
561  chdir($this->cust_lang_path);
562 
563  // get available .lang.local files
564  while ($entry = $d->read()) {
565  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang.local$)~", $entry))) {
566  $lang_key = substr($entry, 6, 2);
567  $local_langs[] = $lang_key;
568  }
569  }
570 
571  chdir($tmpPath);
572  }
573 
574  return $local_langs;
575  }

◆ insertLanguage()

ilSetupLanguage::insertLanguage ( string  $lang_key,
string  $scope = "" 
)
protected

insert language data from file in database

$lang_key international language key (2 digits) $scope empty (global) or "local"

Definition at line 413 of file class.ilSetupLanguage.php.

References ilLanguage\$cust_lang_path, $ilDB, $lang_path, $path, $q, $scope, cut_header(), getLocalChanges(), and null.

Referenced by installLanguages().

413  : void
414  {
415  global $ilDB;
416 
417  $lang_array = array();
418 
419  $scopeExtension = "";
420  if (!empty($scope)) {
421  if ($scope === "global") {
422  $scope = "";
423  } else {
424  $scopeExtension = "." . $scope;
425  }
426  }
427 
429  if ($scope === "local") {
431  }
432 
433  $tmpPath = getcwd();
434  chdir($path);
435 
436  $lang_file = "ilias_" . $lang_key . ".lang" . $scopeExtension;
437  $change_date = null;
438 
439  if (is_file($lang_file)) {
440  // initialize the array for updating lng_modules below
441  $lang_array = [];
442  $lang_array["common"] = [];
443 
444  // remove header first
445  if ($content = $this->cut_header(file($lang_file))) {
446  // get the local changes from the database
447  if (empty($scope)) {
448  $local_changes = $this->getLocalChanges($lang_key);
449  } elseif ($scope === "local") {
450  // set the change date to import time for a local file
451  // get the modification date of the local file
452  // get the newer local changes for a local file
453  $change_date = date("Y-m-d H:i:s", time());
454  $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
455  $local_changes = $this->getLocalChanges($lang_key, $min_date);
456  }
457 
458  $query_check = false;
459  $query = "INSERT INTO lng_data (module,identifier,lang_key,value,local_change,remarks) VALUES ";
460  foreach ($content as $key => $val) {
461  // split the line of the language file
462  // [0]: module
463  // [1]: identifier
464  // [2]: value
465  // [3]: comment (optional)
466  $separated = explode($this->separator, trim($val));
467 
468  //get position of the comment_separator
469  $pos = strpos($separated[2], $this->comment_separator);
470 
471  if ($pos !== false) {
472  //cut comment of
473  $separated[2] = substr($separated[2], 0, $pos);
474  }
475 
476  // check if the value has a local change
477  if (isset($local_changes[$separated[0]])) {
478  $local_value = $local_changes[$separated[0]][$separated[1]] ?? "";
479  } else {
480  $local_value = "";
481  }
482 
483  if (empty($scope)) {
484  if ($local_value !== "" && $local_value !== $separated[2]) {
485  // keep the locally changed value
486  $lang_array[$separated[0]][$separated[1]] = $local_value;
487  continue;
488  }
489  } elseif ($scope === "local") {
490  if ($local_value !== "") {
491  // keep a locally changed value that is newer than the local file
492  $lang_array[$separated[0]][$separated[1]] = $local_value;
493  continue;
494  }
495  }
496 
497  $query .= sprintf(
498  "(%s,%s,%s,%s,%s,%s),",
499  $ilDB->quote($separated[0], "text"),
500  $ilDB->quote($separated[1], "text"),
501  $ilDB->quote($lang_key, "text"),
502  $ilDB->quote($separated[2], "text"),
503  $ilDB->quote($change_date, "timestamp"),
504  $ilDB->quote($separated[3] ?? null, "text")
505  );
506  $query_check = true;
507  $lang_array[$separated[0]][$separated[1]] = $separated[2];
508  }
509  $query = rtrim($query, ",") . " ON DUPLICATE KEY UPDATE value=VALUES(value),remarks=VALUES(remarks);";
510  if ($query_check) {
511  $ilDB->manipulate($query);
512  }
513  }
514 
515  $query = "INSERT INTO lng_modules (module, lang_key, lang_array) VALUES ";
516  $modules_to_delete = [];
517  foreach ($lang_array as $module => $lang_arr) {
518  if ($scope === "local") {
519  $q = "SELECT * FROM lng_modules WHERE " .
520  " lang_key = " . $ilDB->quote($lang_key, "text") .
521  " AND module = " . $ilDB->quote($module, "text");
522  $set = $ilDB->query($q);
523  $row = $ilDB->fetchAssoc($set);
524  $arr2 = unserialize($row["lang_array"], ["allowed_classes" => false]);
525  if (is_array($arr2)) {
526  $lang_arr = array_merge($arr2, $lang_arr);
527  }
528  }
529  $query .= sprintf(
530  "(%s,%s,%s),",
531  $ilDB->quote($module, "text"),
532  $ilDB->quote($lang_key, "text"),
533  $ilDB->quote(serialize($lang_arr), "clob"),
534  );
535  $modules_to_delete[] = $module;
536  }
537 
538  $inModulesToDelete = $ilDB->in('module', $modules_to_delete, false, 'text');
539  $ilDB->manipulate(sprintf(
540  "DELETE FROM lng_modules WHERE lang_key = %s AND $inModulesToDelete",
541  $ilDB->quote($lang_key, "text")
542  ));
543 
544  $query = rtrim($query, ",") . ";";
545  $ilDB->manipulate($query);
546  }
547 
548  chdir($tmpPath);
549  }
$scope
Definition: ltiregstart.php:47
getLocalChanges(string $a_lang_key, string $a_min_date="", string $a_max_date="")
get locally changed language entries $a_lang_key language key $a_min_date minimum change date "yyyy-m...
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
cut_header(array $content)
Remove *.lang header information from &#39;$content&#39;.
$q
Definition: shib_logout.php:21
string $cust_lang_path
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ installLanguages()

ilSetupLanguage::installLanguages ( array  $a_lang_keys,
array  $a_local_keys 
)

install languages

$a_lang_keys array with lang_keys of languages to install

Returns
array|bool

Definition at line 100 of file class.ilSetupLanguage.php.

References $ilDB, $lang_key, checkLanguage(), flushLanguage(), getAvailableLanguages(), and insertLanguage().

101  {
102  global $ilDB;
103 
104  if (empty($a_lang_keys)) {
105  $a_lang_keys = array();
106  }
107 
108  if (empty($a_local_keys)) {
109  $a_local_keys = array();
110  }
111 
112  $err_lang = array();
113 
114  $db_langs = $this->getAvailableLanguages();
115 
116  foreach ($a_lang_keys as $lang_key) {
117  if ($this->checkLanguage($lang_key)) {
118  $this->flushLanguage($lang_key, "keep_local");
119  $this->insertLanguage($lang_key);
120 
121  if (in_array($lang_key, $a_local_keys, true) && is_dir($this->cust_lang_path)) {
122  if ($this->checkLanguage($lang_key, "local")) {
123  $this->insertLanguage($lang_key, "local");
124  } else {
125  $err_lang[] = $lang_key;
126  }
127  }
128 
129  // register language first time install
130  if (!array_key_exists($lang_key, $db_langs)) {
131  if (in_array($lang_key, $a_local_keys, true)) {
132  $itype = "installed_local";
133  } else {
134  $itype = "installed";
135  }
136  $lid = $ilDB->nextId("object_data");
137  $query = "INSERT INTO object_data " .
138  "(obj_id,type,title,description,owner,create_date,last_update) " .
139  "VALUES " .
140  "(" .
141  $ilDB->quote($lid, "integer") . "," .
142  $ilDB->quote("lng", "text") . "," .
143  $ilDB->quote($lang_key, "text") . "," .
144  $ilDB->quote($itype, "text") . "," .
145  $ilDB->quote("-1", "integer") . "," .
146  $ilDB->now() . "," .
147  $ilDB->now() .
148  ")";
149  $ilDB->manipulate($query);
150  }
151  } else {
152  $err_lang[] = $lang_key;
153  }
154  }
155 
156  foreach ($db_langs as $key => $val) {
157  if (!in_array($key, $err_lang, true)) {
158  if (in_array($key, $a_lang_keys, true)) {
159  if (in_array($key, $a_local_keys, true)) {
160  $ld = "installed_local";
161  } else {
162  $ld = "installed";
163  }
164  $query = "UPDATE object_data SET " .
165  "description = " . $ilDB->quote($ld, "text") . ", " .
166  "last_update = " . $ilDB->now() . " " .
167  "WHERE obj_id = " . $ilDB->quote($val["obj_id"], "integer") . " " .
168  "AND type = " . $ilDB->quote("lng", "text");
169  $ilDB->manipulate($query);
170  } else {
171  $this->flushLanguage($key, "all");
172 
173  if (strpos($val["status"], "installed") === 0) {
174  $query = "UPDATE object_data SET " .
175  "description = " . $ilDB->quote("not_installed", "text") . ", " .
176  "last_update = " . $ilDB->now() . " " .
177  "WHERE obj_id = " . $ilDB->quote($val["obj_id"], "integer") . " " .
178  "AND type = " . $ilDB->quote("lng", "text");
179  $ilDB->manipulate($query);
180  }
181  }
182  }
183  }
184 
185  return ($err_lang) ?: true;
186  }
flushLanguage(string $a_lang_key, string $a_mode="all")
remove language data from database $a_lang_key language key $a_mode "all" or "keep_local" ...
checkLanguage(string $a_lang_key, string $scope="")
validate the logical structure of a lang-file
getAvailableLanguages()
get already registered languages (in db)
insertLanguage(string $lang_key, string $scope="")
insert language data from file in database
+ Here is the call graph for this function:

◆ loadLanguageModule()

ilSetupLanguage::loadLanguageModule ( string  $a_module)

Implements ILIAS\Language\Language.

Definition at line 611 of file class.ilSetupLanguage.php.

611  : void
612  {
613  }

◆ setDbHandler()

ilSetupLanguage::setDbHandler ( ilDBInterface  $a_db_handler)

set db handler object object db handler Return true on success

Definition at line 605 of file class.ilSetupLanguage.php.

605  : bool
606  {
607  $this->db = &$a_db_handler;
608  return true;
609  }

◆ txt()

ilSetupLanguage::txt ( string  $a_topic,
string  $a_default_lang_fallback_mod = '' 
)

gets the text for a given topic

if the topic is not in the list, the topic itself with "-" will be returned

$a_topic topic

Implements ILIAS\Language\Language.

Definition at line 67 of file class.ilSetupLanguage.php.

References ilLanguage\$log.

67  : string
68  {
69  global $log;
70 
71  if (empty($a_topic)) {
72  return "";
73  }
74 
75  $translation = $this->text[$a_topic] ?? '';
76 
77  //get position of the comment_separator
78  $pos = strpos($translation, $this->comment_separator);
79 
80  if ($pos !== false) {
81  // remove comment
82  $translation = substr($translation, 0, $pos);
83  }
84 
85  if ($translation === "") {
86  $log->writeLanguageLog($a_topic, $this->lang_key);
87  return "-" . $a_topic . "-";
88  }
89 
90  return $translation;
91  }

Field Documentation

◆ $comment_separator

string ilSetupLanguage::$comment_separator = "###"

Definition at line 49 of file class.ilSetupLanguage.php.

◆ $db

ilDBInterface ilSetupLanguage::$db
protected

Definition at line 50 of file class.ilSetupLanguage.php.

◆ $lang_default

string ilSetupLanguage::$lang_default = "en"

Definition at line 45 of file class.ilSetupLanguage.php.

Referenced by __construct().

◆ $lang_key

string ilSetupLanguage::$lang_key

◆ $lang_path

string ilSetupLanguage::$lang_path

Definition at line 46 of file class.ilSetupLanguage.php.

Referenced by checkLanguage(), and insertLanguage().

◆ $separator

string ilSetupLanguage::$separator = "#:#"

Definition at line 48 of file class.ilSetupLanguage.php.

◆ $text

array ilSetupLanguage::$text

Definition at line 44 of file class.ilSetupLanguage.php.


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