ILIAS  release_8 Revision v8.24
ilSetupLanguage Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

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

Public Member Functions

 __construct (string $a_lang_key)
 Constructor read the single-language file and put this in an array text. More...
 
 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 @string object db handler Return true on success More...
 
 loadLanguageModule (string $a_module)
 Load language module. More...
 
- 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...
 

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

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 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 40 of file class.ilSetupLanguage.php.

Constructor & Destructor Documentation

◆ __construct()

ilSetupLanguage::__construct ( string  $a_lang_key)

Constructor read the single-language file and put this in an array text.

the text array is two-dimensional. First dimension is the language. Second dimension is the languagetopic. Content is the translation.

$a_lang_key language code (two characters), e.g. "de", "en", "in" Return false if reading failed, otherwise true

Reimplemented from ilLanguage.

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

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

References $lang_default.

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 353 of file class.ilSetupLanguage.php.

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

References $ilDB.

Referenced by flushLanguage().

+ Here is the caller graph for this function:

◆ 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 260 of file class.ilSetupLanguage.php.

260 : bool
261 {
262 $scopeExtension = "";
263 if (!empty($scope)) {
264 if ($scope === "global") {
265 $scope = "";
266 } else {
267 $scopeExtension = "." . $scope;
268 }
269 }
270
272 if ($scope === "local") {
274 }
275
276 $tmpPath = getcwd();
277 chdir($path);
278
279 // compute lang-file name format
280 $lang_file = "ilias_" . $a_lang_key . ".lang" . $scopeExtension;
281
282 // file check
283 if (!is_file($lang_file)) {
284 chdir($tmpPath);
285 return false;
286 }
287
288 // header check
289 if (!$content = $this->cut_header(file($lang_file))) {
290 chdir($tmpPath);
291 return false;
292 }
293
294 // check (counting) elements of each lang-entry
295 foreach ($content as $key => $val) {
296 $separated = explode($this->separator, trim($val));
297 $num = count($separated);
298
299 if ($num !== 3) {
300 chdir($tmpPath);
301 return false;
302 }
303 }
304
305 chdir($tmpPath);
306
307 // no error occured
308 return true;
309 }
string $cust_lang_path
cut_header(array $content)
Remove *.lang header information from '$content'.
$scope
Definition: ltiregstart.php:53
$path
Definition: ltiservices.php:32
string $key
Consumer key/client ID value.
Definition: System.php:193

References ilLanguage\$cust_lang_path, ILIAS\LTI\ToolProvider\$key, $lang_path, $path, $scope, and cut_header().

Referenced by installLanguages().

+ 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 321 of file class.ilSetupLanguage.php.

322 {
323 foreach ($content as $key => $val) {
324 if (trim($val) === "<!-- language file start -->") {
325 return array_slice($content, $key + 1);
326 }
327 }
328 return false;
329 }

References ILIAS\LTI\ToolProvider\$key.

Referenced by checkLanguage(), and insertLanguage().

+ 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 336 of file class.ilSetupLanguage.php.

336 : void
337 {
338 global $ilDB;
339
340 self::_deleteLangData($a_lang_key, ($a_mode === "keep_local"));
341
342 if ($a_mode === "all") {
343 $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = " .
344 $ilDB->quote($a_lang_key, "text"));
345 }
346 }
static _deleteLangData(string $a_lang_key, bool $a_keep_local_change)
Delete languge data.

References $ilDB, and _deleteLangData().

Referenced by installLanguages().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableLanguages()

ilSetupLanguage::getAvailableLanguages ( )
protected

get already registered languages (in db)

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

231 : array
232 {
233 global $ilDB;
234
235 $arr = array();
236
237 $query = "SELECT * FROM object_data " .
238 "WHERE type = " . $ilDB->quote("lng", "text");
239 $r = $ilDB->query($query);
240
241 while ($row = $ilDB->fetchObject($r)) {
242 $arr[$row->title]["obj_id"] = $row->obj_id;
243 $arr[$row->title]["status"] = $row->description;
244 }
245
246 return $arr;
247 }
$query

References $ilDB, and $query.

Referenced by installLanguages().

+ Here is the caller graph for this function:

◆ getInstallableLanguages()

ilSetupLanguage::getInstallableLanguages ( )

Return installable languages.

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

575 : array
576 {
577 $d = dir($this->lang_path);
578 $tmpPath = getcwd();
579 chdir($this->lang_path);
580
581 $installableLanguages = [];
582 // get available lang-files
583 while ($entry = $d->read()) {
584 if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry))) {
585 $lang_key = substr($entry, 6, 2);
586 $installableLanguages[] = $lang_key;
587 }
588 }
589
590 chdir($tmpPath);
591
592 return $installableLanguages;
593 }
for( $i=6;$i< 13;$i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296

References $d, and $lang_key.

◆ getInstalledLanguages()

ilSetupLanguage::getInstalledLanguages ( )

get already installed languages (in db)

Reimplemented from ilLanguage.

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

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

References $ilDB, and $query.

◆ getInstalledLocalLanguages()

ilSetupLanguage::getInstalledLocalLanguages ( )

get already installed local languages (in db)

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

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

References $ilDB, and $query.

◆ 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 374 of file class.ilSetupLanguage.php.

374 : array
375 {
376 global $ilDB;
377
378 if ($a_min_date === "") {
379 $a_min_date = "1980-01-01 00:00:00";
380 }
381 if ($a_max_date === "") {
382 $a_max_date = "2200-01-01 00:00:00";
383 }
384
385 $q = sprintf(
386 "SELECT * FROM lng_data WHERE lang_key = %s " .
387 "AND local_change >= %s AND local_change <= %s",
388 $ilDB->quote($a_lang_key, "text"),
389 $ilDB->quote($a_min_date, "timestamp"),
390 $ilDB->quote($a_max_date, "timestamp")
391 );
392 $result = $ilDB->query($q);
393
394 $changes = array();
395 while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
396 $changes[$row["module"]][$row["identifier"]] = $row["value"];
397 }
398 return $changes;
399 }

References $ilDB, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by insertLanguage().

+ 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 550 of file class.ilSetupLanguage.php.

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

References $d, and $lang_key.

◆ 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 409 of file class.ilSetupLanguage.php.

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

References ilLanguage\$cust_lang_path, $ilDB, ILIAS\LTI\ToolProvider\$key, $lang_key, $lang_path, $path, $query, $scope, cut_header(), and getLocalChanges().

Referenced by installLanguages().

+ 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 98 of file class.ilSetupLanguage.php.

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

References $ilDB, ILIAS\LTI\ToolProvider\$key, $lang_key, $query, checkLanguage(), flushLanguage(), getAvailableLanguages(), and insertLanguage().

+ Here is the call graph for this function:

◆ loadLanguageModule()

ilSetupLanguage::loadLanguageModule ( string  $a_module)

Load language module.

Reimplemented from ilLanguage.

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

606 : void
607 {
608 }

◆ setDbHandler()

ilSetupLanguage::setDbHandler ( ilDBInterface  $a_db_handler)

set db handler object @string object db handler Return true on success

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

600 : bool
601 {
602 $this->db = &$a_db_handler;
603 return true;
604 }

◆ 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

Reimplemented from ilLanguage.

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

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

References ilLanguage\$log, and ilLogger\writeLanguageLog().

+ Here is the call graph for this function:

Field Documentation

◆ $comment_separator

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

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

◆ $db

ilDBInterface ilSetupLanguage::$db
protected

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

◆ $lang_default

string ilSetupLanguage::$lang_default = "en"

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

Referenced by __construct().

◆ $lang_key

string ilSetupLanguage::$lang_key

◆ $lang_path

string ilSetupLanguage::$lang_path

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

Referenced by checkLanguage(), and insertLanguage().

◆ $separator

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

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

◆ $text

array ilSetupLanguage::$text

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


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