Started phasing out $opt['rootpath']. Replaced by Config class. Also optimized some class files (cookie, template). Minor changes.
This commit is contained in:
74
htdocs/lib2/translateEdit.class.php
Normal file
74
htdocs/lib2/translateEdit.class.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/***************************************************************************
|
||||
* For license information see doc/license.txt
|
||||
*
|
||||
* Unicode Reminder メモ
|
||||
***************************************************************************/
|
||||
|
||||
class translateEdit extends translate
|
||||
{
|
||||
private $editAll;
|
||||
private $backtrace_level;
|
||||
|
||||
public function __construct($editAll = true, $backtrace_level = 0)
|
||||
{
|
||||
$this->editAll = $editAll;
|
||||
$this->backtrace_level = $backtrace_level;
|
||||
}
|
||||
|
||||
function t($message, $style, $resource_name, $line, $plural='', $count=1, $lang=null)
|
||||
{
|
||||
global $opt;
|
||||
|
||||
if ($message == '')
|
||||
return '';
|
||||
|
||||
if ($message == 'INTERNAL_LANG')
|
||||
return parent::t($message, $style, $resource_name, $line, $plural, $count);
|
||||
|
||||
if ($plural != '' && $count!=1)
|
||||
$message = $plural;
|
||||
|
||||
$search = $this->prepare_text($message);
|
||||
$language = $opt['template']['locale'];
|
||||
|
||||
if (!isset($language))
|
||||
{
|
||||
global $locale;
|
||||
|
||||
$language = $locale;
|
||||
}
|
||||
|
||||
$rs = sql("SELECT `sys_trans`.`id` , `sys_trans_text`.`text` FROM `sys_trans` LEFT JOIN `sys_trans_text` ON `sys_trans`.`id` = `sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang` = '&1' WHERE `sys_trans`.`text` = '&2'", $language, $search);
|
||||
$r = sql_fetch_assoc($rs);
|
||||
|
||||
$trans = $r['text'];
|
||||
$trans = $this->v($trans);
|
||||
|
||||
if ($trans && !$this->editAll)
|
||||
{
|
||||
return $trans;
|
||||
}
|
||||
|
||||
if (empty($r['id']))
|
||||
{
|
||||
global $translationHandler;
|
||||
|
||||
if (empty($resource_name))
|
||||
{
|
||||
$backtrace = debug_backtrace();
|
||||
$item = $backtrace[$this->backtrace_level];
|
||||
$resource_name = $item['file'];
|
||||
$line = $item['line'];
|
||||
}
|
||||
|
||||
$translationHandler->addText($search, $resource_name, $line);
|
||||
|
||||
return $this->t($message, $style, $resource_name, $line, $plural, $count);
|
||||
}
|
||||
|
||||
$text = $trans ? $trans : gettext($search);
|
||||
|
||||
return $text . ' <a href= translate.php?action=edit&id=' . $r['id'] . '>Edit</a>';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user