ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 ()
 
 getTextDirection ()
 
 getContentLanguage ()
 
 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, ilGlobalTemplateInterface $a_tpl=null)
 
 toJSMap ($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 _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...
 

Data Fields

 $ilias
 
 $text
 
 $lang_default
 
 $lang_user
 
 $lang_path
 
 $lang_key
 
 $lang_name
 
 $separator = "#:#"
 
 $comment_separator = "###"
 
 $loaded_modules
 
 $cust_lang_path
 

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
 
 $log
 
 $global_cache
 

Static Protected Attributes

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

Detailed Description

language handling

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

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

Constructor & Destructor Documentation

◆ __construct()

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
string$a_lang_keylanguagecode (two characters), e.g. "de", "en", "in"
Returns
boolean false if reading failed

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

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

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

References $DIC, $ilDB, and $query.

619  {
620  global $DIC;
621 
622  //case $ilDB not existing should not happen but if something went wrong it shouldn't leads to any failures
623  if (!$this->usage_log_enabled || !$DIC->isDependencyAvailable("database")) {
624  return;
625  }
626 
627  $ilDB = $DIC->database();
628 
629  foreach ((array) self::$lng_log as $identifier => $module) {
630  $wave[] = '(' . $ilDB->quote($module, 'text') . ', ' . $ilDB->quote($identifier, 'text') . ')';
631  unset(self::$lng_log[$identifier]);
632 
633  if (count($wave) == 150 || (count(self::$lng_log) == 0 && count($wave) > 0)) {
634  $query = 'REPLACE INTO lng_log (module, identifier) VALUES ' . implode(', ', $wave);
635  $ilDB->manipulate($query);
636 
637  $wave = array();
638  }
639  }
640  }
global $DIC
Definition: goto.php:24
$query
global $ilDB

Member Function Documentation

◆ _getInstalledLanguages()

static ilLanguage::_getInstalledLanguages ( )
static

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

References $lang, and ilObject\_getObjectsByType().

Referenced by ilLanguageDetection\detect(), ilAdvancedMDTranslationGUI\getAvailableLanguagesOptions(), and ilAdvancedMDRecordLanguageTableGUI\parse().

375  {
376  include_once("./Services/Object/classes/class.ilObject.php");
377  $langlist = ilObject::_getObjectsByType("lng");
378 
379  foreach ($langlist as $lang) {
380  if (substr($lang["desc"], 0, 9) == "installed") {
381  $languages[] = $lang["title"];
382  }
383  }
384 
385  return $languages ? $languages : array();
386  }
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
$lang
Definition: xapiexit.php:8
+ 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 388 of file class.ilLanguage.php.

References $DIC, and $ilDB.

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

389  {
390  global $DIC;
391  $ilDB = $DIC->database();
392 
393  $set = $ilDB->query($q = sprintf(
394  "SELECT * FROM lng_data WHERE module = %s " .
395  "AND lang_key = %s AND identifier = %s",
396  $ilDB->quote((string) $a_mod, "text"),
397  $ilDB->quote((string) $a_lang_key, "text"),
398  $ilDB->quote((string) $a_id, "text")
399  ));
400  $rec = $ilDB->fetchAssoc($set);
401 
402  if ($rec["value"] != "") {
403  // remember the used topics
404  self::$used_topics[$a_id] = $a_id;
405  self::$used_modules[$a_mod] = $a_mod;
406 
407  if (self::isUsageLogEnabled()) {
408  self::logUsage($a_mod, $a_id);
409  }
410 
411  return $rec["value"];
412  }
413 
414  return "-" . $a_id . "-";
415  }
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 309 of file class.ilLanguage.php.

310  {
311  return isset($this->text[$a_topic]);
312  }

◆ getContentLanguage()

ilLanguage::getContentLanguage ( )

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

References getLangKey(), and getUserLanguage().

Referenced by getTextDirection().

224  {
225  if ($this->getUserLanguage()) {
226  return $this->getUserLanguage();
227  }
228  return $this->getLangKey();
229  }
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDefaultLanguage()

ilLanguage::getDefaultLanguage ( )

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

210  {
211  return $this->lang_default ? $this->lang_default : 'en';
212  }

◆ getFallbackInstance()

static ilLanguage::getFallbackInstance ( )
static

Builds a global default language instance.

Returns

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

Referenced by ilInitialisation\goToLogin().

462  {
463  return new self('en');
464  }
+ Here is the caller graph for this function:

◆ getGlobalInstance()

static ilLanguage::getGlobalInstance ( )
static

Builds the global language object.

Returns
self

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

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

Referenced by ilInitialisation\goToLogin().

471  {
472  global $DIC;
473  $ilSetting = $DIC->settings();
474  if ($DIC->offsetExists('ilUser')) {
475  $ilUser = $DIC->user();
476  }
477 
478  if (!ilSession::get('lang') && !$_GET['lang']) {
479  if (
480  $ilUser instanceof ilObjUser &&
481  (!$ilUser->getId() || $ilUser->isAnonymous())
482  ) {
483  require_once 'Services/Language/classes/class.ilLanguageDetection.php';
484  $language_detection = new ilLanguageDetection();
485  $language = $language_detection->detect();
486 
487  $ilUser->setPref('language', $language);
488  $_GET['lang'] = $language;
489  }
490  }
491 
492  if (isset($_POST['change_lang_to']) && $_POST['change_lang_to'] != "") {
493  $_GET['lang'] = ilUtil::stripSlashes($_POST['change_lang_to']);
494  }
495 
496  // prefer personal setting when coming from login screen
497  // Added check for ilUser->getId > 0 because it is 0 when the language is changed and the terms of service should be displayed
498  if (
499  $ilUser instanceof ilObjUser &&
500  ($ilUser->getId() && !$ilUser->isAnonymous())
501  ) {
502  ilSession::set('lang', $ilUser->getPref('language'));
503  }
504 
505  ilSession::set('lang', (isset($_GET['lang']) && $_GET['lang']) ? $_GET['lang'] : ilSession::get('lang'));
506 
507  // check whether lang selection is valid
508  $langs = self::_getInstalledLanguages();
509  if (!in_array(ilSession::get('lang'), $langs)) {
510  if ($ilSetting instanceof ilSetting && $ilSetting->get('language') != '') {
511  ilSession::set('lang', $ilSetting->get('language'));
512  } else {
513  ilSession::set('lang', $langs[0]);
514  }
515  }
516  $_GET['lang'] = ilSession::get('lang');
517 
518  return new self(ilSession::get('lang'));
519  }
$_GET["client_id"]
static get($a_var)
Get a value.
static set($a_var, $a_val)
Set a value.
Class ilLanguageDetection.
global $DIC
Definition: goto.php:24
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
global $ilSetting
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:18
$_POST["username"]
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInstalledLanguages()

ilLanguage::getInstalledLanguages ( )

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

Referenced by __construct().

370  {
371  return self::_getInstalledLanguages();
372  }
+ Here is the caller graph for this function:

◆ getLangKey()

ilLanguage::getLangKey ( )

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

References $lang_key.

Referenced by ilForumCronNotificationDataProvider\getAuthorInformation(), and getContentLanguage().

205  {
206  return $this->lang_key;
207  }
+ Here is the caller graph for this function:

◆ getTextDirection()

ilLanguage::getTextDirection ( )

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

References getContentLanguage().

215  {
216  $rtl = array('ar', 'fa', 'ur', 'he');
217  if (in_array($this->getContentLanguage(), $rtl)) {
218  return 'rtl';
219  }
220  return 'ltr';
221  }
+ Here is the call graph for this function:

◆ getUsedModules()

ilLanguage::getUsedModules ( )

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

447  {
448  asort(self::$used_modules);
449  return self::$used_modules;
450  }

◆ getUsedTopics()

ilLanguage::getUsedTopics ( )

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

441  {
442  asort(self::$used_topics);
443  return self::$used_topics;
444  }

◆ getUserLanguage()

ilLanguage::getUserLanguage ( )

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

References $lang_user.

Referenced by getContentLanguage().

453  {
454  return $this->lang_user;
455  }
+ Here is the caller 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 595 of file class.ilLanguage.php.

References $DIC, and $ilDB.

596  {
597  global $DIC;
598  $ilClientIniFile = $DIC->clientIni();
599  $ilDB = $DIC->database();
600 
601  if (!(($ilDB instanceof ilDBMySQL) || ($ilDB instanceof ilDBPdoMySQLMyISAM)) || !$ilClientIniFile instanceof ilIniFile) {
602  return false;
603  }
604 
605  if (defined("DEVMODE") && DEVMODE) {
606  return true;
607  }
608 
609  if (!$ilClientIniFile->variableExists('system', 'LANGUAGE_LOG')) {
610  return $ilClientIniFile->readVariable('system', 'LANGUAGE_LOG') == 1;
611  }
612  return false;
613  }
Class ilDBPdoMySQLMyISAM.
global $DIC
Definition: goto.php:24
global $ilDB
INIFile Parser.

◆ loadLanguageModule()

ilLanguage::loadLanguageModule (   $a_module)

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

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

Referenced by ilDefaultPlaceholderDescription\__construct(), ilCertificateLearningHistoryProvider\__construct(), ilObjStudyProgrammeIndividualPlanGUI\__construct(), ilObjStudyProgrammeTreeGUI\__construct(), ilObjStudyProgrammeMembersGUI\__construct(), ilObjStudyProgrammeSettingsGUI\__construct(), and __construct().

315  {
316  global $DIC;
317  $ilDB = $DIC->database();
318 
319  if (in_array($a_module, $this->loaded_modules)) {
320  return;
321  }
322 
323  $this->loaded_modules[] = $a_module;
324 
325  // remember the used modules globally
326  self::$used_modules[$a_module] = $a_module;
327 
329 
330  if (empty($this->lang_key)) {
332  }
333 
334  if (isset($this->cached_modules[$a_module]) && is_array($this->cached_modules[$a_module])) {
335  $this->text = array_merge($this->text, $this->cached_modules[$a_module]);
336 
337  if ($this->usage_log_enabled) {
338  foreach (array_keys($this->cached_modules[$a_module]) as $key) {
339  $this->map_modules_txt[$key] = $a_module;
340  }
341  }
342 
343  return;
344  }
345 
346  $q = "SELECT * FROM lng_modules " .
347  "WHERE lang_key = " . $ilDB->quote($lang_key, "text") . " AND module = " .
348  $ilDB->quote($a_module, "text");
349  $r = $ilDB->query($q);
350  $row = $r->fetchRow(ilDBConstants::FETCHMODE_ASSOC);
351 
352  if ($row === false) {
353  return;
354  }
355 
356  $new_text = unserialize($row["lang_array"]);
357  if (is_array($new_text)) {
358  $this->text = array_merge($this->text, $new_text);
359 
360  if ($this->usage_log_enabled) {
361  foreach (array_keys($new_text) as $key) {
362  $this->map_modules_txt[$key] = $a_module;
363  }
364  }
365  }
366  }
global $DIC
Definition: goto.php:24
global $ilDB
+ 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 580 of file class.ilLanguage.php.

581  {
582  if ($a_module != "" && $a_identifier != "") {
583  self::$lng_log[$a_identifier] = $a_module;
584  }
585  }

◆ 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 423 of file class.ilLanguage.php.

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

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

424  {
425  global $DIC;
426  $ilDB = $DIC->database();
427 
428  $query = 'SELECT obj_id FROM object_data ' . ' ' .
429  'WHERE title = ' . $ilDB->quote($a_lang_key, 'text') . ' ' .
430  'AND type = ' . $ilDB->quote('lng', 'text');
431 
432  $res = $ilDB->query($query);
433  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
434  return $row->obj_id;
435  }
436  return 0;
437  }
foreach($_POST as $key=> $value) $res
global $DIC
Definition: goto.php:24
$query
global $ilDB
+ Here is the caller graph for this function:

◆ toJS()

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

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

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

528  {
529  global $DIC;
530  $tpl = $DIC['tpl'];
531 
532  if (!is_object($a_tpl)) {
533  $a_tpl = $tpl;
534  }
535 
536  if (!is_array($a_lang_key)) {
537  $a_lang_key = array($a_lang_key);
538  }
539 
540  $map = array();
541  foreach ($a_lang_key as $lk) {
542  $map[$lk] = $this->txt($lk);
543  }
544  $this->toJSMap($map, $a_tpl);
545  }
global $DIC
Definition: goto.php:24
toJSMap($a_map, ilGlobalTemplateInterface $a_tpl=null)
Transfer text to Javascript.
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...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:

◆ toJSMap()

ilLanguage::toJSMap (   $a_map,
ilGlobalTemplateInterface  $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 553 of file class.ilLanguage.php.

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

Referenced by toJS().

554  {
555  global $DIC;
556  $tpl = $DIC['tpl'];
557 
558  if (!is_object($a_tpl)) {
559  $a_tpl = $tpl;
560  }
561 
562  if (!is_array($a_map)) {
563  return;
564  }
565 
566  foreach ($a_map as $k => $v) {
567  if ($v != "") {
568  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
569  $a_tpl->addOnloadCode("il.Language.setLangVar('" . $k . "', " . ilJsonUtil::encode($v) . ");");
570  }
571  }
572  }
static encode($mixed, $suppress_native=false)
global $DIC
Definition: goto.php:24
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ txt()

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 257 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(), ilAssLacUnsupportedExpression\getFormAlert(), ilAssLacUnsupportedOperation\getFormAlert(), ilAssLacUnableToParseCondition\getFormAlert(), ilAssLacOperatorNotSupportedByExpression\getFormAlert(), ilAssLacAnswerIndexNotExist\getFormAlert(), ilAssLacExpressionNotSupportedByQuestion\getFormAlert(), ilAssLacAnswerValueNotExist\getFormAlert(), ilAssQuestionHint\getHintIndexLabel(), assKprimChoice\getInstructionTextTranslation(), ilLearningModuleNotification\getMailBody(), ilLearningModuleNotification\getMailSubject(), ilTestRandomQuestionSetSourcePoolDefinition\getPoolInfoLabel(), ilLearningModuleNotification\getPreviewText(), ilObjTest\getQuestionSetTypeTranslation(), ilTestRandomQuestionsSrcPoolDefinitionQuantitiesCalculation\getRuleSatisfactionResultMessage(), ilObjTestDynamicQuestionSetConfig\getSourceQuestionPoolSummaryString(), ilStudyProgrammeAssessmentSettings\getStatusOptions(), ilAssQuestionLifecycle\getTranslationByIdentifier(), assKprimChoice\getTrueOptionLabelTranslation(), assKprimChoice\getValidOptionLabelsTranslated(), ilCmiXapiVerbList\getVerbTranslation(), ilStudyProgrammeTypeSettings\toFormInput(), ilStudyProgrammeDeadlineSettings\toFormInput(), ilStudyProgrammeTypeInfo\toFormInput(), ilIndividualAssessmentInfoSettings\toFormInput(), ilStudyProgrammeAssessmentSettings\toFormInput(), ilStudyProgrammeValidityOfAchievedQualificationSettings\toFormInput(), ilStudyProgrammeAutoMailSettings\toFormInput(), ilIndividualAssessmentSettings\toFormInput(), ilIndividualAssessmentUserGrading\toFormInput(), toJS(), and txtlng().

258  {
259  if (empty($a_topic)) {
260  return "";
261  }
262 
263  // remember the used topics
264  self::$used_topics[$a_topic] = $a_topic;
265 
266  $translation = "";
267  if (isset($this->text[$a_topic])) {
268  $translation = $this->text[$a_topic];
269  }
270 
271  if ($translation == "" && $a_default_lang_fallback_mod != "") {
272  // #13467 - try current language first (could be missing module)
273  if ($this->lang_key != $this->lang_default) {
274  $translation = ilLanguage::_lookupEntry(
275  $this->lang_key,
276  $a_default_lang_fallback_mod,
277  $a_topic
278  );
279  }
280  // try default language last
281  if ($translation == "" || $translation == "-" . $a_topic . "-") {
282  $translation = ilLanguage::_lookupEntry(
283  $this->lang_default,
284  $a_default_lang_fallback_mod,
285  $a_topic
286  );
287  }
288  }
289 
290 
291  if ($translation == "") {
292  if (ILIAS_LOG_ENABLED && is_object($this->log)) {
293  $this->log->debug("Language (" . $this->lang_key . "): topic -" . $a_topic . "- not present");
294  }
295  return "-" . $a_topic . "-";
296  } else {
297  if ($this->usage_log_enabled) {
298  self::logUsage($this->map_modules_txt[$a_topic], $a_topic);
299  }
300  return $translation;
301  }
302  }
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 240 of file class.ilLanguage.php.

References _lookupEntry(), and txt().

241  {
242  if (strcmp($a_language, $this->lang_key) == 0) {
243  return $this->txt($a_topic);
244  } else {
245  return ilLanguage::_lookupEntry($a_language, $a_module, $a_topic);
246  }
247  }
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:

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.

◆ $cust_lang_path

ilLanguage::$cust_lang_path

◆ $global_cache

ilLanguage::$global_cache
protected

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

◆ $ilias

ilLanguage::$ilias

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

◆ $lang_default

ilLanguage::$lang_default

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

Referenced by __construct().

◆ $lang_key

ilLanguage::$lang_key

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

Referenced by getLangKey(), and loadLanguageModule().

◆ $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.

◆ $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.

◆ $log

ilLanguage::$log
protected

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

Referenced by ilSetupLanguage\txt().

◆ $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

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: