106 $this->separator = $lng->separator;
107 $this->comment_separator = $lng->comment_separator;
109 $this->lang_file = $a_file;
110 $this->lang_key = $a_key;
111 $this->scope = $a_scope;
116 $this->params[
"module"] =
"language file";
117 $this->params[
"modulegroup"] =
"language";
119 if ($this->scope ==
"local")
121 $this->params[
"based_on"] =
"";
125 $this->params[
"author"] =
"";
126 $this->params[
"version"] =
"";
129 $this->params[
"il_server"] = ILIAS_HTTP_PATH;
131 $this->params[
"created"] =
"";
132 $this->params[
"created_by"] =
"";
143 $this->params = array();
144 $this->values = array();
145 $this->comments = array();
146 $this->error_message =
"";
148 $content = file($this->lang_file);
151 foreach ($content as $line_num => $line)
156 if (trim($line) ==
"<!-- language file start -->")
164 $pos_par = strpos($line,
"* @");
166 if ($pos_par !==
false)
169 $pos_space = strpos($line,
" ", $pos_par);
170 $pos_tab = strpos($line,
"\t", $pos_par);
171 $pos_white = min($pos_space, $pos_tab);
173 $param = substr($line, $pos_par, $pos_white-$pos_par);
174 $value = trim(substr($line, $pos_white));
176 $this->params[$param] = $value;
183 $separated = explode($this->separator, trim($line));
186 if (count($separated) != 3)
188 $this->error_message =
189 $lng->txt(
"file_not_valid").
" "
190 .$lng->txt(
"err_in_line").
" ". $line_num .
". "
191 .$lng->txt(
"err_count_param");
196 $key = $separated[0].$this->separator.$separated[1];
197 $value = $separated[2];
200 $pos = strpos($value, $this->comment_separator);
203 $this->comments[$key]
204 = substr($value , $pos + strlen($this->comment_separator));
206 $value = substr($value , 0 , $pos);
208 $this->values[$key] = $value;
215 $this->error_message = $lng->txt(
"file_not_valid").
" ".$lng->txt(
"err_wrong_header");
229 $fp = fopen($this->lang_file,
"w");
230 fwrite($fp, $this->
build());
240 global $ilUser,
$lng;
243 $lang_name = $lng->txtlng(
'common',
'lang_'.$this->lang_key,
'en');
244 $this->params[
"module"] =
"language file ". $lang_name;
245 $this->params[
"created"] = date(
'Y-m-d H:i:s');
246 $this->params[
"created_by"] = $ilUser->getFullname().
" <".$ilUser->getEmail().
">";
249 $tpl =
new ilTemplate(
"tpl.lang_file_header.html",
true,
true,
"Services/Language");
252 $tpl->setCurrentBlock(
'param');
253 $tpl->setVariable(
'PAR_NAME', $name);
254 $tpl->setVariable(
'PAR_VALUE', $value);
255 $tpl->parseCurrentBlock();
257 $txt_scope = $lng->txtlng(
'administration',
'language_scope_'.$this->scope,
'en');
258 $tpl->setVariable(
'SCOPE', $txt_scope,
'en');
261 $content =
$tpl->get();
264 $content .= $key . $this->separator . $value .
"\n";
313 return $this->params[$a_name];
324 return $this->values[$a_module.$this->separator.$a_identifier];
335 return $this->comments[$a_module.$this->separator.$a_identifier];
345 $this->params[$a_name] = $a_value;
354 public function setValue($a_module, $a_identifier, $a_value)
356 $this->values[$a_module.$this->separator.$a_identifier] = $a_value;
365 $this->values = $a_values;
374 public function setComment($a_module, $a_identifier, $a_value)
376 return $this->comments[$a_module.$this->separator.$a_identifier] = $a_comment;
388 if (!isset(self::$global_file_objects[$a_lang_key]))
391 $lng->lang_path .
"/ilias_" . $a_lang_key .
".lang",
392 $a_lang_key,
'global');
393 $file_object->read();
395 self::$global_file_objects[$a_lang_key] = $file_object;
398 return self::$global_file_objects[$a_lang_key];