159        $this->log = 
$DIC->logger()->root();
 
  161        $this->lang_key = $a_lang_key;
 
  163        $this->text = array();
 
  164        $this->loaded_modules = array();
 
  168        $this->lang_path = ILIAS_ABSOLUTE_PATH . 
"/lang";
 
  169        $this->cust_lang_path = ILIAS_ABSOLUTE_PATH . 
"/Customizing/global/lang";
 
  171        $this->lang_default = 
$ilIliasIniFile->readVariable(
"language", 
"default");
 
  173        if (
$DIC->offsetExists(
'ilSetting')) {
 
  176                $this->lang_default = 
$ilSetting->get(
"language");
 
  179        if (
$DIC->offsetExists(
'ilUser')) {
 
  181            $this->lang_user = 
$ilUser->prefs[
"language"];
 
  186        if (!in_array($this->lang_key, $langs)) {
 
  190        require_once(
'./Services/Language/classes/class.ilCachedLanguage.php');
 
  192        if ($this->global_cache->isActive()) {
 
  193            $this->cached_modules = $this->global_cache->getTranslations();
 
  208        return $this->lang_default ? $this->lang_default : 
'en';
 
  220    public function txtlng($a_module, $a_topic, $a_language)
 
  222        if (strcmp($a_language, $this->lang_key) == 0) {
 
  223            return $this->
txt($a_topic);
 
  237    public function txt($a_topic, $a_default_lang_fallback_mod = 
"")
 
  239        if (empty($a_topic)) {
 
  244        self::$used_topics[$a_topic] = $a_topic;
 
  247        if (isset($this->text[$a_topic])) {
 
  248            $translation = $this->text[$a_topic];
 
  251        if ($translation == 
"" && $a_default_lang_fallback_mod != 
"") {
 
  253            if ($this->lang_key != $this->lang_default) {
 
  256                    $a_default_lang_fallback_mod,
 
  261            if ($translation == 
"" || $translation == 
"-" . $a_topic . 
"-") {
 
  264                    $a_default_lang_fallback_mod,
 
  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");
 
  275            return "-" . $a_topic . 
"-";
 
  277            if ($this->usage_log_enabled) {
 
  291        return isset($this->text[$a_topic]);
 
  299        if (in_array($a_module, $this->loaded_modules)) {
 
  303        $this->loaded_modules[] = $a_module;
 
  306        self::$used_modules[$a_module] = $a_module;
 
  310        if (empty($this->lang_key)) {
 
  314        if (is_array($this->cached_modules[$a_module])) {
 
  315            $this->text = array_merge($this->text, $this->cached_modules[$a_module]);
 
  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;
 
  326        $q = 
"SELECT * FROM lng_modules " .
 
  327                "WHERE lang_key = " . 
$ilDB->quote(
$lang_key, 
"text") . 
" AND module = " .
 
  328                $ilDB->quote($a_module, 
"text");
 
  332        $new_text = unserialize(
$row[
"lang_array"]);
 
  333        if (is_array($new_text)) {
 
  334            $this->text = array_merge($this->text, $new_text);
 
  336            if ($this->usage_log_enabled) {
 
  337                foreach (array_keys($new_text) as 
$key) {
 
  338                    $this->map_modules_txt[
$key] = $a_module;
 
  352        include_once(
"./Services/Object/classes/class.ilObject.php");
 
  355        foreach ($langlist as 
$lang) {
 
  356            if (substr(
$lang[
"desc"], 0, 9) == 
"installed") {
 
  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")
 
  376        $rec = 
$ilDB->fetchAssoc($set);
 
  378        if ($rec[
"value"] != 
"") {
 
  380            self::$used_topics[$a_id] = $a_id;
 
  381            self::$used_modules[$a_mod] = $a_mod;
 
  383            if (self::isUsageLogEnabled()) {
 
  387            return $rec[
"value"];
 
  390        return "-" . $a_id . 
"-";
 
  404        $query = 
'SELECT obj_id FROM object_data ' . 
' ' .
 
  405        'WHERE title = ' . 
$ilDB->quote($a_lang_key, 
'text') . 
' ' .
 
  406            'AND type = ' . 
$ilDB->quote(
'lng', 
'text');
 
  418        asort(self::$used_topics);
 
  424        asort(self::$used_modules);
 
  439        return new self(
'en');
 
  450        if (
$DIC->offsetExists(
'ilUser')) {
 
  459                require_once 
'Services/Language/classes/class.ilLanguageDetection.php';
 
  461                $language = $language_detection->detect();
 
  468        if (isset(
$_POST[
'change_lang_to']) && 
$_POST[
'change_lang_to'] != 
"") {
 
  508        if (!is_object($a_tpl)) {
 
  512        if (!is_array($a_lang_key)) {
 
  513            $a_lang_key = array($a_lang_key);
 
  517        foreach ($a_lang_key as $lk) {
 
  534        if (!is_object($a_tpl)) {
 
  538        if (!is_array($a_map)) {
 
  542        foreach ($a_map as $k => $v) {
 
  544                include_once(
"./Services/JSON/classes/class.ilJsonUtil.php");
 
  545                $a_tpl->addOnloadCode(
"il.Language.setLangVar('" . $k . 
"', " . 
ilJsonUtil::encode($v) . 
");");
 
  556    protected static function logUsage($a_module, $a_identifier)
 
  558        if ($a_module != 
"" && $a_identifier != 
"") {
 
  559            self::$lng_log[$a_identifier] = $a_module;
 
  574        $ilClientIniFile = 
$DIC->clientIni();
 
  585        if (!$ilClientIniFile->variableExists(
'system', 
'LANGUAGE_LOG')) {
 
  586            return $ilClientIniFile->readVariable(
'system', 
'LANGUAGE_LOG') == 1;
 
  599        if (!$this->usage_log_enabled || !
$DIC->isDependencyAvailable(
"database")) {
 
  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]);
 
  609            if (count($wave) == 150 || (count(self::$lng_log) == 0 && count($wave) > 0)) {
 
  610                $query = 
'REPLACE INTO lng_log (module, identifier) VALUES ' . implode(
', ', $wave);
 
An exception for terminatinating execution or to throw for unit testing.
Class ilDBPdoMySQLMyISAM.
static encode($mixed, $suppress_native=false)
Class ilLanguageDetection.
static getFallbackInstance()
Builds a global default language instance.
loadLanguageModule($a_module)
toJSMap($a_map, ilTemplate $a_tpl=null)
Transfer text to Javascript.
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,...
static _getInstalledLanguages()
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...
static isUsageLogEnabled()
checks if language usage log is enabled you need MySQL to use this function this function is automati...
static logUsage($a_module, $a_identifier)
saves tupel of language module and identifier
static _lookupEntry($a_lang_key, $a_mod, $a_id)
__destruct()
destructor saves all language usages to db if log is enabled and ilDB exists
static lookupId($a_lang_key)
Lookup obj_id of language @global ilDB $ilDB.
__construct($a_lang_key)
Constructor read the single-language file and put this in an array text.
static getGlobalInstance()
Builds the global language object.
exists($a_topic)
Check if language entry exists.
toJS($a_lang_key, ilTemplate $a_tpl=null)
static _getObjectsByType($a_obj_type="", $a_owner="")
Get objects by type.
static set($a_var, $a_val)
Set a value.
static get($a_var)
Get a value.
special template class to simplify handling of ITX/PEAR
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
for($i=1; $i<=count($kw_cases_sel); $i+=1) $lang
if($modEnd===false) $module
foreach($_POST as $key=> $value) $res