ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilLanguage Class Reference

language handling More...

+ Inheritance diagram for ilLanguage:
+ Collaboration diagram for ilLanguage:

Public Member Functions

 __construct ($a_lang_key)
 Constructor read the single-language file and put this in an array text. More...
 
 getLangKey ()
 
 getDefaultLanguage ()
 
 txtlng ($a_module, $a_topic, $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 ($a_topic, $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 ($a_topic)
 Check if language entry exists. More...
 
 loadLanguageModule ($a_module)
 
 getInstalledLanguages ()
 
 getUsedTopics ()
 
 getUsedModules ()
 
 getUserLanguage ()
 
 toJS ($a_lang_key, ilTemplate $a_tpl=null)
 
 toJSMap ($a_map, ilTemplate $a_tpl=null)
 Transfer text to Javascript. More...
 
 __destruct ()
 destructor saves all language usages to db if log is enabled and ilDB exists More...
 
 __construct ($a_lang_key)
 Constructor read the single-language file and put this in an array text. More...
 
 txt ($a_topic)
 gets the text for a given topic More...
 
 getLanguages ()
 get all setup languages in the system More...
 
 installLanguages ($a_lang_keys, $a_local_keys)
 install languages More...
 
 getInstalledLanguages ()
 get already installed languages (in db) More...
 
 getInstalledLocalLanguages ()
 get already installed local languages (in db) More...
 
 getAvailableLanguages ()
 get already registered languages (in db) More...
 
 checkLanguage ($a_lang_key, $scope='')
 validate the logical structure of a lang-file More...
 
 cut_header ($content)
 Remove *.lang header information from '$content'. More...
 
 flushLanguage ($a_lang_key, $a_mode='all')
 remove language data from database More...
 
 getLocalChanges ($a_lang_key, $a_min_date="", $a_max_date="")
 get locally changed language entries More...
 
 insertLanguage ($lang_key, $scope='')
 insert language data from file in database More...
 
 getLocalLanguages ()
 Searches for the existence of *.lang.local files. More...
 
 getInstallableLanguages ()
 
 setDbHandler ($a_db_handler)
 set db handler object object db handler More...
 
 loadLanguageModule ()
 

Static Public Member Functions

static _getInstalledLanguages ()
 
static _lookupEntry ($a_lang_key, $a_mod, $a_id)
 
static lookupId ($a_lang_key)
 Lookup obj_id of language ilDB $ilDB. More...
 
static getFallbackInstance ()
 Builds a global default language instance. More...
 
static getGlobalInstance ()
 Builds the global language object. More...
 
static _deleteLangData ($a_lang_key, $a_keep_local_change)
 Delete languge data. More...
 
static replaceLangModule ($a_key, $a_module, $a_array)
 Replace language module array. More...
 
static replaceLangEntry ( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
 Replace lang entry. More...
 
static updateLangEntry ( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
 Update lang entry. More...
 

Data Fields

 $ilias
 
 $text = array()
 
 $lang_default = "en"
 
 $lang_user
 
 $lang_path
 
 $lang_key
 
 $lang_name
 
 $separator = "#:#"
 
 $comment_separator = "###"
 
 $loaded_modules
 

Static Protected Member Functions

static logUsage ($a_module, $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...
 

Protected Attributes

 $cached_modules = array()
 
 $map_modules_txt = array()
 
 $usage_log_enabled = false
 

Static Protected Attributes

static $used_topics = array()
 
static $used_modules = array()
 
static $lng_log = array()
 

Detailed Description

language handling

language handling for setup

this class offers the language handling for an application. it works initially on one file: languages.txt from this file the class can generate many single language files. 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:
Das Datefeld wird bei Aenderungen einer Sprache (update, install, deinstall) nicht richtig gesetzt!!! Die Formatfunktionen gehoeren nicht in class.Language. Die sind auch woanders einsetzbar!!! Daher->besser in class.Format

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

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

Constructor & Destructor Documentation

◆ __construct() [1/2]

ilLanguage::__construct (   $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.

public

Parameters
stringlanguagecode (two characters), e.g. "de", "en", "in"
Returns
boolean false if reading failed

Definition at line 154 of file class.ilLanguage.php.

References $DIC, $ilIliasIniFile, $ilSetting, $ilUser, $lang_default, getInstalledLanguages(), ilCachedLanguage\getInstance(), and loadLanguageModule().

155  {
156  global $DIC;
157  $ilIliasIniFile = $DIC->iliasIni();
158 
159  $this->log = $DIC->logger()->root();
160 
161  $this->lang_key = $a_lang_key;
162 
163  $this->text = array();
164  $this->loaded_modules = array();
165 
166  $this->usage_log_enabled = self::isUsageLogEnabled();
167 
168  $this->lang_path = ILIAS_ABSOLUTE_PATH . "/lang";
169  $this->cust_lang_path = ILIAS_ABSOLUTE_PATH . "/Customizing/global/lang";
170 
171  $this->lang_default = $ilIliasIniFile->readVariable("language", "default");
172 
173  if ($DIC->offsetExists('ilSetting')) {
174  $ilSetting = $DIC->settings();
175  if ($ilSetting->get("language") != "") {
176  $this->lang_default = $ilSetting->get("language");
177  }
178  }
179  if ($DIC->offsetExists('ilUser')) {
180  $ilUser = $DIC->user();
181  $this->lang_user = $ilUser->prefs["language"];
182  }
183 
184  $langs = $this->getInstalledLanguages();
185 
186  if (!in_array($this->lang_key, $langs)) {
187  $this->lang_key = $this->lang_default;
188  }
189 
190  require_once('./Services/Language/classes/class.ilCachedLanguage.php');
191  $this->global_cache = ilCachedLanguage::getInstance($this->lang_key);
192  if ($this->global_cache->isActive()) {
193  $this->cached_modules = $this->global_cache->getTranslations();
194  }
195 
196  $this->loadLanguageModule("common");
197 
198  return true;
199  }
global $DIC
Definition: saml.php:7
$ilUser
Definition: imgupload.php:18
global $ilSetting
Definition: privfeed.php:17
$ilIliasIniFile
+ Here is the call graph for this function:

◆ __destruct()

ilLanguage::__destruct ( )

destructor saves all language usages to db if log is enabled and ilDB exists

Definition at line 594 of file class.ilLanguage.php.

References $DIC, $ilDB, $module, and $query.

595  {
596  global $DIC;
597 
598  //case $ilDB not existing should not happen but if something went wrong it shouldn't leads to any failures
599  if (!$this->usage_log_enabled || !$DIC->isDependencyAvailable("database")) {
600  return;
601  }
602 
603  $ilDB = $DIC->database();
604 
605  foreach ((array) self::$lng_log as $identifier => $module) {
606  $wave[] = '(' . $ilDB->quote($module, 'text') . ', ' . $ilDB->quote($identifier, 'text') . ')';
607  unset(self::$lng_log[$identifier]);
608 
609  if (count($wave) == 150 || (count(self::$lng_log) == 0 && count($wave) > 0)) {
610  $query = 'REPLACE INTO lng_log (module, identifier) VALUES ' . implode(', ', $wave);
611  $ilDB->manipulate($query);
612 
613  $wave = array();
614  }
615  }
616  }
global $DIC
Definition: saml.php:7
if($modEnd===false) $module
Definition: module.php:59
$query
global $ilDB

◆ __construct() [2/2]

ilLanguage::__construct (   $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. public

Parameters
stringlanguagecode (two characters), e.g. "de", "en", "in"
Returns
boolean false if reading failed

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

References $row, and $txt.

101  {
102  $this->lang_key = ($a_lang_key) ? $a_lang_key : $this->lang_default;
103  $this->lang_path = ILIAS_ABSOLUTE_PATH . "/lang";
104  $this->cust_lang_path = ILIAS_ABSOLUTE_PATH . "/Customizing/global/lang";
105 
106  // set lang file...
107  $txt = file($this->lang_path . "/setup_lang_sel_multi.lang");
108 
109  // ...and load langdata
110  if (is_array($txt)) {
111  foreach ($txt as $row) {
112  if ($row[0] != "#") {
113  $a = explode($this->separator, trim($row));
114  $this->text[trim($a[0])] = trim($a[1]);
115  }
116  }
117  }
118 
119  // set lang file...
120  $txt = file($this->lang_path . "/setup_" . $this->lang_key . ".lang");
121 
122  // ...and load langdata
123  if (is_array($txt)) {
124  foreach ($txt as $row) {
125  if ($row[0] != "#") {
126  $a = explode($this->separator, trim($row));
127  $this->text[trim($a[0])] = trim($a[1]);
128  }
129  }
130 
131  return true;
132  }
133 
134  return false;
135  }
$txt
Definition: error.php:11
$row

Member Function Documentation

◆ _deleteLangData()

static ilLanguage::_deleteLangData (   $a_lang_key,
  $a_keep_local_change 
)
static

Delete languge data.

Parameters
stringlang key

Definition at line 466 of file class.ilLanguage.php.

References $ilDB.

Referenced by flushLanguage().

467  {
468  global $ilDB;
469 
470  if (!$a_keep_local_change) {
471  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
472  $ilDB->quote($a_lang_key, "text"));
473  } else {
474  $ilDB->manipulate("DELETE FROM lng_data WHERE lang_key = " .
475  $ilDB->quote($a_lang_key, "text") .
476  " AND local_change IS NULL");
477  }
478  }
global $ilDB
+ Here is the caller graph for this function:

◆ _getInstalledLanguages()

static ilLanguage::_getInstalledLanguages ( )
static

Definition at line 350 of file class.ilLanguage.php.

References $lang, $languages, and ilObject\_getObjectsByType().

Referenced by ilLanguageDetection\detect().

351  {
352  include_once("./Services/Object/classes/class.ilObject.php");
353  $langlist = ilObject::_getObjectsByType("lng");
354 
355  foreach ($langlist as $lang) {
356  if (substr($lang["desc"], 0, 9) == "installed") {
357  $languages[] = $lang["title"];
358  }
359  }
360 
361  return $languages ? $languages : array();
362  }
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
Definition: langwiz.php:349
$languages
Definition: cssgen2.php:34
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ _lookupEntry()

static ilLanguage::_lookupEntry (   $a_lang_key,
  $a_mod,
  $a_id 
)
static

Definition at line 364 of file class.ilLanguage.php.

References $DIC, and $ilDB.

Referenced by ilLinkChecker\__txt(), ilObjLTIAdministrationGUI\getConsumerForm(), ilPersonalSettingsGUI\initGeneralSettingsForm(), ilAccountMail\replacePlaceholders(), ilUserCronCheckAccounts\txt(), txt(), and txtlng().

365  {
366  global $DIC;
367  $ilDB = $DIC->database();
368 
369  $set = $ilDB->query($q = sprintf(
370  "SELECT * FROM lng_data WHERE module = %s " .
371  "AND lang_key = %s AND identifier = %s",
372  $ilDB->quote((string) $a_mod, "text"),
373  $ilDB->quote((string) $a_lang_key, "text"),
374  $ilDB->quote((string) $a_id, "text")
375  ));
376  $rec = $ilDB->fetchAssoc($set);
377 
378  if ($rec["value"] != "") {
379  // remember the used topics
380  self::$used_topics[$a_id] = $a_id;
381  self::$used_modules[$a_mod] = $a_mod;
382 
383  if (self::isUsageLogEnabled()) {
384  self::logUsage($a_mod, $a_id);
385  }
386 
387  return $rec["value"];
388  }
389 
390  return "-" . $a_id . "-";
391  }
global $DIC
Definition: saml.php:7
global $ilDB
+ Here is the caller graph for this function:

◆ checkLanguage()

ilLanguage::checkLanguage (   $a_lang_key,
  $scope = '' 
)

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).

Parameters
string$a_lang_keyinternational language key (2 digits)
string$scopeempty (global) or "local"
Returns
string $info_text message about results of check OR "1" if all checks successfully passed

Definition at line 372 of file class.ilLanguage.php.

References $key, $lang_path, $path, and cut_header().

Referenced by installLanguages().

373  {
374  if (!empty($scope)) {
375  if ($scope == 'global') {
376  $scope = '';
377  } else {
378  $scopeExtension = '.' . $scope;
379  }
380  }
381 
383  if ($scope == "local") {
384  $path = $this->cust_lang_path;
385  }
386 
387  $tmpPath = getcwd();
388  chdir($path);
389 
390  // compute lang-file name format
391  $lang_file = "ilias_" . $a_lang_key . ".lang" . $scopeExtension;
392 
393  // file check
394  if (!is_file($lang_file)) {
395  chdir($tmpPath);
396  return false;
397  }
398 
399  // header check
400  if (!$content = $this->cut_header(file($lang_file))) {
401  chdir($tmpPath);
402  return false;
403  }
404 
405  // check (counting) elements of each lang-entry
406  foreach ($content as $key => $val) {
407  $separated = explode($this->separator, trim($val));
408  $num = count($separated);
409 
410  if ($num != 3) {
411  chdir($tmpPath);
412  return false;
413  }
414  }
415 
416  chdir($tmpPath);
417 
418  // no error occured
419  return true;
420  }
$path
Definition: aliased.php:25
cut_header($content)
Remove *.lang header information from &#39;$content&#39;.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ cut_header()

ilLanguage::cut_header (   $content)

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.

Parameters
string$contentexpect an ILIAS lang-file
Returns
string $content content without header info OR false if no valid header was found private

Definition at line 432 of file class.ilLanguage.php.

References $key.

Referenced by checkLanguage(), and insertLanguage().

433  {
434  foreach ($content as $key => $val) {
435  if (trim($val) == "<!-- language file start -->") {
436  return array_slice($content, $key + 1);
437  }
438  }
439 
440  return false;
441  }
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ exists()

ilLanguage::exists (   $a_topic)

Check if language entry exists.

Parameters
object$a_topic
Returns

Definition at line 289 of file class.ilLanguage.php.

290  {
291  return isset($this->text[$a_topic]);
292  }

◆ flushLanguage()

ilLanguage::flushLanguage (   $a_lang_key,
  $a_mode = 'all' 
)

remove language data from database

Parameters
stringlanguage key
string"all" or "keep_local"

Definition at line 449 of file class.ilLanguage.php.

References $ilDB, and _deleteLangData().

Referenced by installLanguages().

450  {
451  $ilDB = $this->db;
452 
453  ilLanguage::_deleteLangData($a_lang_key, ($a_mode == 'keep_local'));
454 
455  if ($a_mode == 'all') {
456  $ilDB->manipulate("DELETE FROM lng_modules WHERE lang_key = " .
457  $ilDB->quote($a_lang_key, "text"));
458  }
459  }
static _deleteLangData($a_lang_key, $a_keep_local_change)
Delete languge data.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAvailableLanguages()

ilLanguage::getAvailableLanguages ( )

get already registered languages (in db)

Returns
array array with information about languages that has been registered in db

Definition at line 343 of file class.ilLanguage.php.

References $ilDB, $query, $r, and $row.

Referenced by installLanguages().

344  {
345  global $ilDB;
346 
347  $arr = array();
348 
349  $query = "SELECT * FROM object_data " .
350  "WHERE type = " . $ilDB->quote("lng", "text");
351  $r = $ilDB->query($query);
352 
353  while ($row = $ilDB->fetchObject($r)) {
354  $arr[$row->title]["obj_id"] = $row->obj_id;
355  $arr[$row->title]["status"] = $row->description;
356  }
357 
358  return $arr;
359  }
$r
Definition: example_031.php:79
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getDefaultLanguage()

ilLanguage::getDefaultLanguage ( )

Definition at line 206 of file class.ilLanguage.php.

207  {
208  return $this->lang_default ? $this->lang_default : 'en';
209  }

◆ getFallbackInstance()

static ilLanguage::getFallbackInstance ( )
static

Builds a global default language instance.

Returns

Definition at line 437 of file class.ilLanguage.php.

Referenced by ilInitialisation\goToLogin().

438  {
439  return new self('en');
440  }
+ Here is the caller graph for this function:

◆ getGlobalInstance()

static ilLanguage::getGlobalInstance ( )
static

Builds the global language object.

Returns
self

Definition at line 446 of file class.ilLanguage.php.

References $_GET, $_POST, $DIC, $ilSetting, $ilUser, $language, ilSession\get(), ilSession\set(), and ilUtil\stripSlashes().

Referenced by ilInitialisation\goToLogin().

447  {
448  global $DIC;
449  $ilSetting = $DIC->settings();
450  if ($DIC->offsetExists('ilUser')) {
451  $ilUser = $DIC->user();
452  }
453 
454  if (!ilSession::get('lang') && !$_GET['lang']) {
455  if (
456  $ilUser instanceof ilObjUser &&
457  (!$ilUser->getId() || $ilUser->isAnonymous())
458  ) {
459  require_once 'Services/Language/classes/class.ilLanguageDetection.php';
460  $language_detection = new ilLanguageDetection();
461  $language = $language_detection->detect();
462 
463  $ilUser->setPref('language', $language);
464  $_GET['lang'] = $language;
465  }
466  }
467 
468  if (isset($_POST['change_lang_to']) && $_POST['change_lang_to'] != "") {
469  $_GET['lang'] = ilUtil::stripSlashes($_POST['change_lang_to']);
470  }
471 
472  // prefer personal setting when coming from login screen
473  // Added check for ilUser->getId > 0 because it is 0 when the language is changed and the terms of service should be displayed
474  if (
475  $ilUser instanceof ilObjUser &&
476  ($ilUser->getId() && !$ilUser->isAnonymous())
477  ) {
478  ilSession::set('lang', $ilUser->getPref('language'));
479  }
480 
481  ilSession::set('lang', (isset($_GET['lang']) && $_GET['lang']) ? $_GET['lang'] : ilSession::get('lang'));
482 
483  // check whether lang selection is valid
484  $langs = self::_getInstalledLanguages();
485  if (!in_array(ilSession::get('lang'), $langs)) {
486  if ($ilSetting instanceof ilSetting && $ilSetting->get('language') != '') {
487  ilSession::set('lang', $ilSetting->get('language'));
488  } else {
489  ilSession::set('lang', $langs[0]);
490  }
491  }
492  $_GET['lang'] = ilSession::get('lang');
493 
494  return new self(ilSession::get('lang'));
495  }
global $DIC
Definition: saml.php:7
$_GET["client_id"]
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
Class ilLanguageDetection.
$ilUser
Definition: imgupload.php:18
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilSetting
Definition: privfeed.php:17
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstallableLanguages()

ilLanguage::getInstallableLanguages ( )

Definition at line 747 of file class.ilLanguage.php.

References $d, $lang_key, and getLanguages().

748  {
749  $setup_langs = $this->getLanguages();
750 
751  $d = dir($this->lang_path);
752  $tmpPath = getcwd();
753  chdir($this->lang_path);
754 
755  // get available lang-files
756  while ($entry = $d->read()) {
757  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang$)~", $entry))) {
758  $lang_key = substr($entry, 6, 2);
759  $languages1[] = $lang_key;
760  }
761  }
762 
763  //$languages = array_intersect($languages1,$setup_langs);
764 
765  chdir($tmpPath);
766 
767  return $languages1;
768  }
getLanguages()
get all setup languages in the system
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ Here is the call graph for this function:

◆ getInstalledLanguages() [1/2]

ilLanguage::getInstalledLanguages ( )

get already installed languages (in db)

Returns
array array with inforamtion about each installed language

Definition at line 298 of file class.ilLanguage.php.

References $ilDB, $query, $r, and $row.

299  {
300  global $ilDB;
301 
302  $arr = array();
303 
304  $query = "SELECT * FROM object_data " .
305  "WHERE type = " . $ilDB->quote("lng", "text") . " " .
306  "AND " . $ilDB->like("description", "text", 'installed%');
307  $r = $ilDB->query($query);
308 
309  while ($row = $ilDB->fetchObject($r)) {
310  $arr[] = $row->title;
311  }
312 
313  return $arr;
314  }
$r
Definition: example_031.php:79
$query
$row
global $ilDB

◆ getInstalledLanguages() [2/2]

ilLanguage::getInstalledLanguages ( )

Definition at line 345 of file class.ilLanguage.php.

Referenced by __construct().

346  {
347  return self::_getInstalledLanguages();
348  }
+ Here is the caller graph for this function:

◆ getInstalledLocalLanguages()

ilLanguage::getInstalledLocalLanguages ( )

get already installed local languages (in db)

Returns
array array with inforamtion about each installed language

Definition at line 321 of file class.ilLanguage.php.

References $ilDB, $query, $r, and $row.

322  {
323  global $ilDB;
324 
325  $arr = array();
326 
327  $query = "SELECT * FROM object_data " .
328  "WHERE type = " . $ilDB->quote("lng", "text") . " " .
329  "AND description = " . $ilDB->quote('installed_local', "text");
330  $r = $ilDB->query($query);
331 
332  while ($row = $ilDB->fetchObject($r)) {
333  $arr[] = $row->title;
334  }
335 
336  return $arr;
337  }
$r
Definition: example_031.php:79
$query
$row
global $ilDB

◆ getLangKey()

ilLanguage::getLangKey ( )

Definition at line 201 of file class.ilLanguage.php.

References $lang_key.

Referenced by ilForumCronNotificationDataProvider\getAuthorInformation().

202  {
203  return $this->lang_key;
204  }
+ Here is the caller graph for this function:

◆ getLanguages()

ilLanguage::getLanguages ( )

get all setup languages in the system

the functions looks for setup*.lang-files in the languagedirectory public

Returns
array langs

Definition at line 178 of file class.ilLanguage.php.

References $d, $lang_key, and $languages.

Referenced by getInstallableLanguages().

179  {
180  $d = dir($this->lang_path);
181  $tmpPath = getcwd();
182  chdir($this->lang_path);
183 
184  // get available setup-files
185  while ($entry = $d->read()) {
186  if (is_file($entry) && (preg_match('/(^setup_.{2}\.lang$)/', $entry))) {
187  $lang_key = substr($entry, 6, 2);
188  $languages[] = $lang_key;
189  }
190  }
191 
192  chdir($tmpPath);
193 
194  return $languages;
195  }
$languages
Definition: cssgen2.php:34
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ Here is the caller graph for this function:

◆ getLocalChanges()

ilLanguage::getLocalChanges (   $a_lang_key,
  $a_min_date = "",
  $a_max_date = "" 
)

get locally changed language entries

Parameters
stringlanguage key
stringminimum change date "yyyy-mm-dd hh:mm:ss"
stringmaximum change date "yyyy-mm-dd hh:mm:ss"
Returns
array [module][identifier] => value

Definition at line 487 of file class.ilLanguage.php.

References $ilDB, $result, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by insertLanguage().

488  {
489  $ilDB = $this->db;
490 
491  if ($a_min_date == "") {
492  $a_min_date = "1980-01-01 00:00:00";
493  }
494  if ($a_max_date == "") {
495  $a_max_date = "2200-01-01 00:00:00";
496  }
497 
498  $q = sprintf(
499  "SELECT * FROM lng_data WHERE lang_key = %s " .
500  "AND local_change >= %s AND local_change <= %s",
501  $ilDB->quote($a_lang_key, "text"),
502  $ilDB->quote($a_min_date, "timestamp"),
503  $ilDB->quote($a_max_date, "timestamp")
504  );
505  $result = $ilDB->query($q);
506 
507  $changes = array();
508  while ($row = $result->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) {
509  $changes[$row["module"]][$row["identifier"]] = $row["value"];
510  }
511  return $changes;
512  }
$result
$row
global $ilDB
+ Here is the caller graph for this function:

◆ getLocalLanguages()

ilLanguage::getLocalLanguages ( )

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

return $local_langs array of language keys

Definition at line 725 of file class.ilLanguage.php.

References $d, and $lang_key.

726  {
727  $local_langs = array();
728  if (is_dir($this->cust_lang_path)) {
729  $d = dir($this->cust_lang_path);
730  $tmpPath = getcwd();
731  chdir($this->cust_lang_path);
732 
733  // get available .lang.local files
734  while ($entry = $d->read()) {
735  if (is_file($entry) && (preg_match("~(^ilias_.{2}\.lang.local$)~", $entry))) {
736  $lang_key = substr($entry, 6, 2);
737  $local_langs[] = $lang_key;
738  }
739  }
740 
741  chdir($tmpPath);
742  }
743 
744  return $local_langs;
745  }
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296

◆ getUsedModules()

ilLanguage::getUsedModules ( )

Definition at line 422 of file class.ilLanguage.php.

423  {
424  asort(self::$used_modules);
425  return self::$used_modules;
426  }

◆ getUsedTopics()

ilLanguage::getUsedTopics ( )

Definition at line 416 of file class.ilLanguage.php.

417  {
418  asort(self::$used_topics);
419  return self::$used_topics;
420  }

◆ getUserLanguage()

ilLanguage::getUserLanguage ( )

Definition at line 428 of file class.ilLanguage.php.

References $lang_user.

429  {
430  return $this->lang_user;
431  }

◆ insertLanguage()

ilLanguage::insertLanguage (   $lang_key,
  $scope = '' 
)

insert language data from file in database

Parameters
string$lang_keyinternational language key (2 digits)
string$scopeempty (global) or "local"
Returns
void

Definition at line 523 of file class.ilLanguage.php.

References $ilDB, $key, $lang_key, $lang_path, $module, $path, $row, cut_header(), getLocalChanges(), replaceLangEntry(), replaceLangModule(), and updateLangEntry().

Referenced by installLanguages().

524  {
525  $ilDB = &$this->db;
526 
527  $lang_array = array();
528 
529  if (!empty($scope)) {
530  if ($scope == 'global') {
531  $scope = '';
532  } else {
533  $scopeExtension = '.' . $scope;
534  }
535  }
536 
538  if ($scope == "local") {
539  $path = $this->cust_lang_path;
540  }
541 
542  $tmpPath = getcwd();
543  chdir($path);
544 
545  $lang_file = "ilias_" . $lang_key . ".lang" . $scopeExtension;
546 
547  if (is_file($lang_file)) {
548  // initialize the array for updating lng_modules below
549  $lang_array = array();
550  $lang_array["common"] = array();
551 
552  // remove header first
553  if ($content = $this->cut_header(file($lang_file))) {
554  // get the local changes from the database
555  if (empty($scope)) {
556  $local_changes = $this->getLocalChanges($lang_key);
557  } elseif ($scope == 'local') {
558  // set the change date to import time for a local file
559  // get the modification date of the local file
560  // get the newer local changes for a local file
561  $change_date = date("Y-m-d H:i:s", time());
562  $min_date = date("Y-m-d H:i:s", filemtime($lang_file));
563  $local_changes = $this->getLocalChanges($lang_key, $min_date);
564  }
565 
566  foreach ($content as $key => $val) {
567  // split the line of the language file
568  // [0]: module
569  // [1]: identifier
570  // [2]: value
571  // [3]: comment (optional)
572  $separated = explode($this->separator, trim($val));
573 
574  //get position of the comment_separator
575  $pos = strpos($separated[2], $this->comment_separator);
576 
577  if ($pos !== false) {
578  //cut comment of
579  $separated[2] = substr($separated[2], 0, $pos);
580  }
581 
582  // check if the value has a local change
583  $local_value = $local_changes[$separated[0]][$separated[1]];
584 
585  if (empty($scope)) {
586  if ($local_value != "" and $local_value != $separated[2]) {
587  // keep the locally changed value
588  $lang_array[$separated[0]][$separated[1]] = $local_value;
589  } else {
590  // insert a new value if no local value exists
591  // reset local_change if the values are equal
593  $separated[0],
594  $separated[1],
595  $lang_key,
596  $separated[2]
597  );
598 
599  $lang_array[$separated[0]][$separated[1]] = $separated[2];
600  }
601  } elseif ($scope == 'local') {
602  if ($local_value != "") {
603  // keep a locally changed value that is newer than the local file
604  $lang_array[$separated[0]][$separated[1]] = $local_value;
605  } else {
606  // UPDATE because the global values have already been INSERTed
608  $separated[0],
609  $separated[1],
610  $lang_key,
611  $separated[2],
612  $change_date
613  );
614  $lang_array[$separated[0]][$separated[1]] = $separated[2];
615  }
616  }
617  }
618  }
619 
620  foreach ($lang_array as $module => $lang_arr) {
621  if ($scope == "local") {
622  $q = "SELECT * FROM lng_modules WHERE " .
623  " lang_key = " . $ilDB->quote($lang_key, "text") .
624  " AND module = " . $ilDB->quote($module, "text");
625  $set = $ilDB->query($q);
626  $row = $ilDB->fetchAssoc($set);
627  $arr2 = unserialize($row["lang_array"]);
628  if (is_array($arr2)) {
629  $lang_arr = array_merge($arr2, $lang_arr);
630  }
631  }
633  }
634  }
635 
636  chdir($tmpPath);
637  }
static replaceLangModule($a_key, $a_module, $a_array)
Replace language module array.
$path
Definition: aliased.php:25
if($modEnd===false) $module
Definition: module.php:59
cut_header($content)
Remove *.lang header information from &#39;$content&#39;.
getLocalChanges($a_lang_key, $a_min_date="", $a_max_date="")
get locally changed language entries
static replaceLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
Replace lang entry.
$row
global $ilDB
static updateLangEntry( $a_module, $a_identifier, $a_lang_key, $a_value, $a_local_change=null)
Update lang entry.
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ installLanguages()

ilLanguage::installLanguages (   $a_lang_keys,
  $a_local_keys 
)

install languages

Parameters
arrayarray with lang_keys of languages to install
Returns
boolean true on success

Definition at line 203 of file class.ilLanguage.php.

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

204  {
205  global $ilDB;
206 
207  if (empty($a_lang_keys)) {
208  $a_lang_keys = array();
209  }
210 
211  if (empty($a_local_keys)) {
212  $a_local_keys = array();
213  }
214 
215  $err_lang = array();
216 
217  $db_langs = $this->getAvailableLanguages();
218 
219  foreach ($a_lang_keys as $lang_key) {
220  if ($this->checkLanguage($lang_key)) {
221  $this->flushLanguage($lang_key, 'keep_local');
222  $this->insertLanguage($lang_key);
223 
224  if (in_array($lang_key, $a_local_keys)) {
225  if ($this->checkLanguage($lang_key, "local")) {
226  $this->insertLanguage($lang_key, "local");
227  } else {
228  $err_lang[] = $lang_key;
229  }
230  }
231 
232  // register language first time install
233  if (!array_key_exists($lang_key, $db_langs)) {
234  if (in_array($lang_key, $a_local_keys)) {
235  $itype = 'installed_local';
236  } else {
237  $itype = 'installed';
238  }
239  $lid = $ilDB->nextId("object_data");
240  $query = "INSERT INTO object_data " .
241  "(obj_id,type,title,description,owner,create_date,last_update) " .
242  "VALUES " .
243  "(" .
244  $ilDB->quote($lid, "integer") . "," .
245  $ilDB->quote("lng", "text") . "," .
246  $ilDB->quote($lang_key, "text") . "," .
247  $ilDB->quote($itype, "text") . "," .
248  $ilDB->quote('-1', "integer") . "," .
249  $ilDB->now() . "," .
250  $ilDB->now() .
251  ")";
252  $this->db->manipulate($query);
253  }
254  } else {
255  $err_lang[] = $lang_key;
256  }
257  }
258 
259  foreach ($db_langs as $key => $val) {
260  if (!in_array($key, $err_lang)) {
261  if (in_array($key, $a_lang_keys)) {
262  if (in_array($key, $a_local_keys)) {
263  $ld = 'installed_local';
264  } else {
265  $ld = 'installed';
266  }
267  $query = "UPDATE object_data SET " .
268  "description = " . $ilDB->quote($ld, "text") . ", " .
269  "last_update = " . $ilDB->now() . " " .
270  "WHERE obj_id = " . $ilDB->quote($val["obj_id"], "integer") . " " .
271  "AND type = " . $ilDB->quote("lng", "text");
272  $ilDB->manipulate($query);
273  } else {
274  $this->flushLanguage($key, "all");
275 
276  if (substr($val["status"], 0, 9) == "installed") {
277  $query = "UPDATE object_data SET " .
278  "description = " . $ilDB->quote("not_installed", "text") . ", " .
279  "last_update = " . $ilDB->now() . " " .
280  "WHERE obj_id = " . $ilDB->quote($val["obj_id"], "integer") . " " .
281  "AND type = " . $ilDB->quote("lng", "text");
282  $ilDB->manipulate($query);
283  }
284  }
285  }
286  }
287 
288  return ($err_lang) ? $err_lang : true;
289  }
getAvailableLanguages()
get already registered languages (in db)
checkLanguage($a_lang_key, $scope='')
validate the logical structure of a lang-file
$ld
Definition: langwiz.php:244
flushLanguage($a_lang_key, $a_mode='all')
remove language data from database
$query
insertLanguage($lang_key, $scope='')
insert language data from file in database
global $ilDB
$key
Definition: croninfo.php:18
+ Here is the call graph for this function:

◆ isUsageLogEnabled()

static ilLanguage::isUsageLogEnabled ( )
staticprotected

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

Returns
bool

Definition at line 571 of file class.ilLanguage.php.

References $DIC, and $ilDB.

572  {
573  global $DIC;
574  $ilClientIniFile = $DIC->clientIni();
575  $ilDB = $DIC->database();
576 
577  if (!(($ilDB instanceof ilDBMySQL) || ($ilDB instanceof ilDBPdoMySQLMyISAM)) || !$ilClientIniFile instanceof ilIniFile) {
578  return false;
579  }
580 
581  if (DEVMODE) {
582  return true;
583  }
584 
585  if (!$ilClientIniFile->variableExists('system', 'LANGUAGE_LOG')) {
586  return $ilClientIniFile->readVariable('system', 'LANGUAGE_LOG') == 1;
587  }
588  return false;
589  }
global $DIC
Definition: saml.php:7
Class ilDBPdoMySQLMyISAM.
global $ilDB
INIFile Parser.

◆ loadLanguageModule() [1/2]

ilLanguage::loadLanguageModule (   $a_module)

Definition at line 294 of file class.ilLanguage.php.

References $DIC, $ilDB, $key, $lang_key, $lang_user, $r, $row, and ilDBConstants\FETCHMODE_ASSOC.

Referenced by ilCertificateLearningHistoryProvider\__construct(), and ilObjUserGUI\showUpperIcon().

295  {
296  global $DIC;
297  $ilDB = $DIC->database();
298 
299  if (in_array($a_module, $this->loaded_modules)) {
300  return;
301  }
302 
303  $this->loaded_modules[] = $a_module;
304 
305  // remember the used modules globally
306  self::$used_modules[$a_module] = $a_module;
307 
309 
310  if (empty($this->lang_key)) {
312  }
313 
314  if (is_array($this->cached_modules[$a_module])) {
315  $this->text = array_merge($this->text, $this->cached_modules[$a_module]);
316 
317  if ($this->usage_log_enabled) {
318  foreach (array_keys($this->cached_modules[$a_module]) as $key) {
319  $this->map_modules_txt[$key] = $a_module;
320  }
321  }
322 
323  return;
324  }
325 
326  $q = "SELECT * FROM lng_modules " .
327  "WHERE lang_key = " . $ilDB->quote($lang_key, "text") . " AND module = " .
328  $ilDB->quote($a_module, "text");
329  $r = $ilDB->query($q);
331 
332  $new_text = unserialize($row["lang_array"]);
333  if (is_array($new_text)) {
334  $this->text = array_merge($this->text, $new_text);
335 
336  if ($this->usage_log_enabled) {
337  foreach (array_keys($new_text) as $key) {
338  $this->map_modules_txt[$key] = $a_module;
339  }
340  }
341  }
342  }
global $DIC
Definition: saml.php:7
$r
Definition: example_031.php:79
$row
global $ilDB
$key
Definition: croninfo.php:18
+ Here is the caller graph for this function:

◆ loadLanguageModule() [2/2]

ilLanguage::loadLanguageModule ( )

Definition at line 786 of file class.ilLanguage.php.

Referenced by __construct().

787  {
788  }
+ Here is the caller graph for this function:

◆ logUsage()

static ilLanguage::logUsage (   $a_module,
  $a_identifier 
)
staticprotected

saves tupel of language module and identifier

Parameters
string$a_module
string$a_identifier

Definition at line 556 of file class.ilLanguage.php.

557  {
558  if ($a_module != "" && $a_identifier != "") {
559  self::$lng_log[$a_identifier] = $a_module;
560  }
561  }

◆ lookupId()

static ilLanguage::lookupId (   $a_lang_key)
static

Lookup obj_id of language ilDB $ilDB.

Parameters
string$a_lang_key
Returns
int

Definition at line 399 of file class.ilLanguage.php.

References $DIC, $ilDB, $query, $res, $row, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilStartUpGUI\getLoginPageEditorHTML(), and ilAuthLoginPageEditorTableGUI\parse().

400  {
401  global $DIC;
402  $ilDB = $DIC->database();
403 
404  $query = 'SELECT obj_id FROM object_data ' . ' ' .
405  'WHERE title = ' . $ilDB->quote($a_lang_key, 'text') . ' ' .
406  'AND type = ' . $ilDB->quote('lng', 'text');
407 
408  $res = $ilDB->query($query);
409  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
410  return $row->obj_id;
411  }
412  return 0;
413  }
global $DIC
Definition: saml.php:7
foreach($_POST as $key=> $value) $res
$query
$row
global $ilDB
+ Here is the caller graph for this function:

◆ replaceLangEntry()

static ilLanguage::replaceLangEntry (   $a_module,
  $a_identifier,
  $a_lang_key,
  $a_value,
  $a_local_change = null 
)
staticfinal

Replace lang entry.

Definition at line 665 of file class.ilLanguage.php.

References $ilDB.

Referenced by insertLanguage().

671  {
672  global $ilDB;
673 
674  $ilDB->manipulate(sprintf(
675  "DELETE FROM lng_data WHERE module = %s AND " .
676  "identifier = %s AND lang_key = %s",
677  $ilDB->quote($a_module, "text"),
678  $ilDB->quote($a_identifier, "text"),
679  $ilDB->quote($a_lang_key, "text")
680  ));
681 
682  // insert a new value if no local value exists
683  // reset local_change if the values are equal
684  $ilDB->manipulate(sprintf(
685  "INSERT INTO lng_data " .
686  "(module, identifier, lang_key, value, local_change) " .
687  "VALUES (%s,%s,%s,%s,%s)",
688  $ilDB->quote($a_module, "text"),
689  $ilDB->quote($a_identifier, "text"),
690  $ilDB->quote($a_lang_key, "text"),
691  $ilDB->quote($a_value, "text"),
692  $ilDB->quote($a_local_change, "timestamp")
693  ));
694  }
global $ilDB
+ Here is the caller graph for this function:

◆ replaceLangModule()

static ilLanguage::replaceLangModule (   $a_key,
  $a_module,
  $a_array 
)
staticfinal

Replace language module array.

Definition at line 642 of file class.ilLanguage.php.

References $ilDB.

Referenced by insertLanguage().

643  {
644  global $ilDB;
645 
646  $ilDB->manipulate(sprintf(
647  "DELETE FROM lng_modules WHERE lang_key = %s AND module = %s",
648  $ilDB->quote($a_key, "text"),
649  $ilDB->quote($a_module, "text")
650  ));
651  /*$ilDB->manipulate(sprintf("INSERT INTO lng_modules (lang_key, module, lang_array) VALUES ".
652  "(%s,%s,%s)", $ilDB->quote($a_key, "text"),
653  $ilDB->quote($a_module, "text"),
654  $ilDB->quote(serialize($a_array), "clob")));*/
655  $ilDB->insert("lng_modules", array(
656  "lang_key" => array("text", $a_key),
657  "module" => array("text", $a_module),
658  "lang_array" => array("clob", serialize($a_array))
659  ));
660  }
global $ilDB
+ Here is the caller graph for this function:

◆ setDbHandler()

ilLanguage::setDbHandler (   $a_db_handler)

set db handler object object db handler

Returns
boolean true on success

Definition at line 775 of file class.ilLanguage.php.

776  {
777  if (empty($a_db_handler) or !is_object($a_db_handler)) {
778  return false;
779  }
780 
781  $this->db = &$a_db_handler;
782 
783  return true;
784  }

◆ toJS()

ilLanguage::toJS (   $a_lang_key,
ilTemplate  $a_tpl = null 
)

Definition at line 503 of file class.ilLanguage.php.

References $DIC, $map, $tpl, toJSMap(), and txt().

504  {
505  global $DIC;
506  $tpl = $DIC['tpl'];
507 
508  if (!is_object($a_tpl)) {
509  $a_tpl = $tpl;
510  }
511 
512  if (!is_array($a_lang_key)) {
513  $a_lang_key = array($a_lang_key);
514  }
515 
516  $map = array();
517  foreach ($a_lang_key as $lk) {
518  $map[$lk] = $this->txt($lk);
519  }
520  $this->toJSMap($map, $a_tpl);
521  }
toJSMap($a_map, ilTemplate $a_tpl=null)
Transfer text to Javascript.
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
txt($a_topic, $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 re...
+ Here is the call graph for this function:

◆ toJSMap()

ilLanguage::toJSMap (   $a_map,
ilTemplate  $a_tpl = null 
)

Transfer text to Javascript.

Parameters
array$a_maparray of key value pairs (key is text string, value is content)
ilTemplate$a_tpltemplate

Definition at line 529 of file class.ilLanguage.php.

References $DIC, $tpl, and ilJsonUtil\encode().

Referenced by toJS().

530  {
531  global $DIC;
532  $tpl = $DIC['tpl'];
533 
534  if (!is_object($a_tpl)) {
535  $a_tpl = $tpl;
536  }
537 
538  if (!is_array($a_map)) {
539  return;
540  }
541 
542  foreach ($a_map as $k => $v) {
543  if ($v != "") {
544  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
545  $a_tpl->addOnloadCode("il.Language.setLangVar('" . $k . "', " . ilJsonUtil::encode($v) . ");");
546  }
547  }
548  }
global $DIC
Definition: saml.php:7
$tpl
Definition: ilias.php:10
static encode($mixed, $suppress_native=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ txt() [1/2]

ilLanguage::txt (   $a_topic)

gets the text for a given topic

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

Parameters
stringtopic
Returns
string text clear-text

Definition at line 145 of file class.ilLanguage.php.

References $log.

146  {
147  global $log;
148 
149  if (empty($a_topic)) {
150  return "";
151  }
152 
153  $translation = $this->text[$a_topic];
154 
155  //get position of the comment_separator
156  $pos = strpos($translation, $this->comment_separator);
157 
158  if ($pos !== false) {
159  // remove comment
160  $translation = substr($translation, 0, $pos);
161  }
162 
163  if ($translation == "") {
164  $log->writeLanguageLog($a_topic, $this->lang_key);
165  return "-" . $a_topic . "-";
166  } else {
167  return $translation;
168  }
169  }
$log
Definition: sabredav.php:21

◆ txt() [2/2]

ilLanguage::txt (   $a_topic,
  $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

public

Parameters
stringtopic
Returns
string text clear-text

Definition at line 237 of file class.ilLanguage.php.

References _lookupEntry().

Referenced by ilDefaultPlaceholderDescription\__construct(), ilTestRandomQuestionsSrcPoolDefinitionQuantitiesCalculation\buildIntersectionQuestionSharingDefinitionsString(), assKprimChoice\getAnswerTypeSelectOptions(), ilTestRandomQuestionsSrcPoolDefinitionQuantitiesCalculation\getConcurrentRuleConflictMessage(), ilObjTestDynamicQuestionSetConfig\getDepenciesBrokenMessage(), ilTestRandomQuestionSetConfig\getDepenciesBrokenMessage(), ilObjTestDynamicQuestionSetConfig\getDepenciesInVulnerableStateMessage(), ilAssQuestionSkillAssignmentImportFails\getFailedImportsMessage(), ilTestSkillLevelThresholdImportFails\getFailedImportsMessage(), assKprimChoice\getFalseOptionLabelTranslation(), ilAssLacConditionParserException\getFormAlert(), ilAssLacDuplicateElement\getFormAlert(), ilAssLacMissingBracket\getFormAlert(), ilAssLacQuestionNotExist\getFormAlert(), ilAssLacQuestionNotReachable\getFormAlert(), ilAssLacUnsupportedOperation\getFormAlert(), ilAssLacUnsupportedExpression\getFormAlert(), ilAssLacUnableToParseCondition\getFormAlert(), ilAssLacOperatorNotSupportedByExpression\getFormAlert(), ilAssLacAnswerIndexNotExist\getFormAlert(), ilAssLacExpressionNotSupportedByQuestion\getFormAlert(), ilAssLacAnswerValueNotExist\getFormAlert(), ilAssQuestionHint\getHintIndexLabel(), assKprimChoice\getInstructionTextTranslation(), ilTestRandomQuestionSetSourcePoolDefinition\getPoolInfoLabel(), ilObjTest\getQuestionSetTypeTranslation(), ilTestRandomQuestionsSrcPoolDefinitionQuantitiesCalculation\getRuleSatisfactionResultMessage(), ilObjTestDynamicQuestionSetConfig\getSourceQuestionPoolSummaryString(), assKprimChoice\getTrueOptionLabelTranslation(), assKprimChoice\getValidOptionLabelsTranslated(), toJS(), and txtlng().

238  {
239  if (empty($a_topic)) {
240  return "";
241  }
242 
243  // remember the used topics
244  self::$used_topics[$a_topic] = $a_topic;
245 
246  $translation = "";
247  if (isset($this->text[$a_topic])) {
248  $translation = $this->text[$a_topic];
249  }
250 
251  if ($translation == "" && $a_default_lang_fallback_mod != "") {
252  // #13467 - try current language first (could be missing module)
253  if ($this->lang_key != $this->lang_default) {
254  $translation = ilLanguage::_lookupEntry(
255  $this->lang_key,
256  $a_default_lang_fallback_mod,
257  $a_topic
258  );
259  }
260  // try default language last
261  if ($translation == "" || $translation == "-" . $a_topic . "-") {
262  $translation = ilLanguage::_lookupEntry(
263  $this->lang_default,
264  $a_default_lang_fallback_mod,
265  $a_topic
266  );
267  }
268  }
269 
270 
271  if ($translation == "") {
272  if (ILIAS_LOG_ENABLED && is_object($this->log)) {
273  $this->log->debug("Language (" . $a_lang_key . "): topic -" . $a_topic . "- not present");
274  }
275  return "-" . $a_topic . "-";
276  } else {
277  if ($this->usage_log_enabled) {
278  self::logUsage($this->map_modules_txt[$a_topic], $a_topic);
279  }
280  return $translation;
281  }
282  }
static _lookupEntry($a_lang_key, $a_mod, $a_id)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ txtlng()

ilLanguage::txtlng (   $a_module,
  $a_topic,
  $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

public

Parameters
stringtopic
string$a_languageThe language of the output string
Returns
string text clear-text

Definition at line 220 of file class.ilLanguage.php.

References _lookupEntry(), and txt().

221  {
222  if (strcmp($a_language, $this->lang_key) == 0) {
223  return $this->txt($a_topic);
224  } else {
225  return ilLanguage::_lookupEntry($a_language, $a_module, $a_topic);
226  }
227  }
static _lookupEntry($a_lang_key, $a_mod, $a_id)
txt($a_topic, $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 re...
+ Here is the call graph for this function:

◆ updateLangEntry()

static ilLanguage::updateLangEntry (   $a_module,
  $a_identifier,
  $a_lang_key,
  $a_value,
  $a_local_change = null 
)
staticfinal

Update lang entry.

Definition at line 699 of file class.ilLanguage.php.

References $ilDB.

Referenced by insertLanguage().

705  {
706  global $ilDB;
707 
708  $ilDB->manipulate(sprintf(
709  "UPDATE lng_data " .
710  "SET value = %s, local_change = %s " .
711  "WHERE module = %s AND identifier = %s AND lang_key = %s ",
712  $ilDB->quote($a_value, "text"),
713  $ilDB->quote($a_local_change, "timestamp"),
714  $ilDB->quote($a_module, "text"),
715  $ilDB->quote($a_identifier, "text"),
716  $ilDB->quote($a_lang_key, "text")
717  ));
718  }
global $ilDB
+ Here is the caller graph for this function:

Field Documentation

◆ $cached_modules

ilLanguage::$cached_modules = array()
protected

Definition at line 127 of file class.ilLanguage.php.

◆ $comment_separator

ilLanguage::$comment_separator = "###"

Definition at line 103 of file class.ilLanguage.php.

◆ $ilias

ilLanguage::$ilias

Definition at line 34 of file class.ilLanguage.php.

◆ $lang_default

ilLanguage::$lang_default = "en"

Definition at line 51 of file class.ilLanguage.php.

Referenced by __construct().

◆ $lang_key

◆ $lang_name

ilLanguage::$lang_name

Definition at line 87 of file class.ilLanguage.php.

◆ $lang_path

ilLanguage::$lang_path

Definition at line 71 of file class.ilLanguage.php.

Referenced by checkLanguage(), and insertLanguage().

◆ $lang_user

ilLanguage::$lang_user

Definition at line 61 of file class.ilLanguage.php.

Referenced by getUserLanguage(), and loadLanguageModule().

◆ $lng_log

ilLanguage::$lng_log = array()
staticprotected

Definition at line 142 of file class.ilLanguage.php.

◆ $loaded_modules

ilLanguage::$loaded_modules

Definition at line 111 of file class.ilLanguage.php.

◆ $map_modules_txt

ilLanguage::$map_modules_txt = array()
protected

Definition at line 132 of file class.ilLanguage.php.

◆ $separator

ilLanguage::$separator = "#:#"

Definition at line 95 of file class.ilLanguage.php.

◆ $text

ilLanguage::$text = array()

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

◆ $usage_log_enabled

ilLanguage::$usage_log_enabled = false
protected

Definition at line 137 of file class.ilLanguage.php.

◆ $used_modules

ilLanguage::$used_modules = array()
staticprotected

Definition at line 123 of file class.ilLanguage.php.

◆ $used_topics

ilLanguage::$used_topics = array()
staticprotected

Definition at line 117 of file class.ilLanguage.php.


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