forked from extern/egroupware
* Custom / instance-specific translations, eg. to rename an application
This commit is contained in:
parent
f255a2396a
commit
f2d7c5c6c3
97
admin/inc/class.admin_customtranslation.inc.php
Normal file
97
admin/inc/class.admin_customtranslation.inc.php
Normal file
@ -0,0 +1,97 @@
|
||||
<?php
|
||||
/**
|
||||
* EGgroupware admin - custom translations
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
|
||||
* @package admin
|
||||
* @copyright (c) 2011 by Ralf Becker <rb@stylite.de>
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* Custom - instance specific - translations
|
||||
*/
|
||||
class admin_customtranslation
|
||||
{
|
||||
/**
|
||||
* Which methods of this class can be called as menuation
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $public_functions = array(
|
||||
'index' => true,
|
||||
);
|
||||
|
||||
/**
|
||||
* Add, modify, delete custom translations
|
||||
*
|
||||
* @param array $content=null
|
||||
* @param string $msg=''
|
||||
*/
|
||||
function index(array $content=null, $msg='')
|
||||
{
|
||||
if (is_array($content))
|
||||
{
|
||||
//_debug_array($content);
|
||||
if (isset($content['button']))
|
||||
{
|
||||
list($action) = each($content['button']);
|
||||
unset($content['button']);
|
||||
}
|
||||
elseif($content['rows']['delete'])
|
||||
{
|
||||
list($action) = each($content['rows']['delete']);
|
||||
unset($content['rows']['delete']);
|
||||
}
|
||||
switch($action)
|
||||
{
|
||||
case 'save':
|
||||
case 'apply':
|
||||
$saved = 0;
|
||||
foreach($content['rows'] as $n => $data)
|
||||
{
|
||||
if (!empty($data['phrase']))
|
||||
{
|
||||
translation::write('en', 'custom', strtolower(trim($data['phrase'])), $data['translation']);
|
||||
++$saved;
|
||||
}
|
||||
}
|
||||
if ($saved) $msg = lang('%1 phrases saved.', $saved);
|
||||
if ($action == 'apply') break;
|
||||
// fall through
|
||||
case 'cancel':
|
||||
egw::redirect_link('/admin/index.php');
|
||||
break;
|
||||
|
||||
default: // line to delete;
|
||||
if (!empty($content['rows'][$action]['phrase']))
|
||||
{
|
||||
translation::write('en', 'custom', strtolower(trim($content['rows'][$action]['phrase'])), null);
|
||||
$msg = lang('Phrase deleted');
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
$content = array('rows' => array());
|
||||
foreach(translation::load_app('custom', 'en') as $phrase => $translation)
|
||||
{
|
||||
$content['rows'][++$row] = array(
|
||||
'phrase' => $phrase,
|
||||
'translation' => $translation,
|
||||
);
|
||||
}
|
||||
// one empty line to add new translations
|
||||
$content['rows'][++$row] = array(
|
||||
'phrase' => '',
|
||||
'translation' => '',
|
||||
);
|
||||
$readonlys["delete[$row]"] = true; // no delete for empty row
|
||||
$content['msg'] = $msg;
|
||||
|
||||
$GLOBALS['egw_info']['flags']['app_header'] = lang('Custom translation');
|
||||
$tpl = new etemplate('admin.customtranslation');
|
||||
$tpl->exec('admin.admin_customtranslation.index', $content, $sel_options, $readonlys, $preserv);
|
||||
}
|
||||
}
|
@ -117,6 +117,7 @@ class admin_prefs_sidebox_hooks
|
||||
}
|
||||
$file['Admin queue and history'] = egw::link('/index.php','menuaction=admin.admin_cmds.index');
|
||||
$file['Remote administration instances'] = egw::link('/index.php','menuaction=admin.admin_cmds.remotes');
|
||||
$file['Custom translation'] = egw::link('/index.php','menuaction=admin.admin_customtranslation.index');
|
||||
|
||||
$file['Submit statistic information'] = egw::link('/index.php','menuaction=admin.admin_statistics.submit');
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* EGroupware - eTemplates for Application admin
|
||||
* http://www.egroupware.org
|
||||
* generated by soetemplate::dump4setup() 2011-08-03 16:07
|
||||
* generated by soetemplate::dump4setup() 2011-11-17 13:27
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package admin
|
||||
@ -81,6 +81,8 @@ $templ_data[] = array('name' => 'admin.customfields.fields','template' => '','la
|
||||
|
||||
$templ_data[] = array('name' => 'admin.customfields.types','template' => '','lang' => '','group' => '0','version' => '1.2','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:4:{s:1:"D";s:15:",@non_deletable";s:1:"E";s:8:",@no_add";s:1:"F";s:8:",@no_add";s:2:"h1";s:15:",@no_edit_types";}i:1;a:6:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:8:"app-name";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:7:"- type";}s:1:"C";a:4:{s:4:"type";s:6:"select";s:4:"name";s:5:"types";s:8:"onchange";s:1:"1";s:7:"no_lang";s:1:"1";}s:1:"D";a:4:{s:4:"type";s:6:"button";s:5:"label";s:6:"Delete";s:4:"name";s:6:"delete";s:7:"onclick";s:110:"return confirm(\'WARNING: You are about to delete this type. Entries of this type won\\\'t be accessable then.\');";}s:1:"E";a:3:{s:4:"type";s:4:"text";s:4:"name";s:4:"name";s:4:"blur";s:8:"new name";}s:1:"F";a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Create";s:4:"name";s:6:"create";}}}s:4:"rows";i:1;s:4:"cols";i:6;}}','size' => '','style' => '','modified' => '1139823458',);
|
||||
|
||||
$templ_data[] = array('name' => 'admin.customtranslation','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:3:{i:0;a:3:{s:4:"type";s:5:"label";s:4:"name";s:3:"msg";s:4:"span";s:10:",redItalic";}i:1;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:1:{s:2:"c1";s:2:"th";}i:1;a:3:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Phrase";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:5:"label";s:11:"Translation";}s:1:"C";a:2:{s:4:"type";s:5:"label";s:5:"label";s:6:"Action";}}i:2;a:3:{s:1:"A";a:3:{s:4:"type";s:4:"text";s:4:"size";s:2:"64";s:4:"name";s:14:"${row}[phrase]";}s:1:"B";a:3:{s:4:"type";s:4:"text";s:4:"size";s:2:"64";s:4:"name";s:19:"${row}[translation]";}s:1:"C";a:6:{s:4:"type";s:6:"button";s:4:"size";s:6:"delete";s:5:"label";s:6:"Delete";s:5:"align";s:6:"center";s:4:"name";s:12:"delete[$row]";s:7:"onclick";s:25:"return confirm(\'Delete\');";}}}s:4:"rows";i:2;s:4:"cols";i:3;s:4:"name";s:4:"rows";s:7:"options";a:0:{}}i:2;a:5:{s:4:"type";s:4:"hbox";s:4:"size";s:1:"3";i:1;a:3:{s:4:"type";s:6:"button";s:5:"label";s:4:"Save";s:4:"name";s:12:"button[save]";}i:2;a:3:{s:4:"type";s:6:"button";s:5:"label";s:5:"Apply";s:4:"name";s:13:"button[apply]";}i:3;a:3:{s:4:"type";s:6:"button";s:5:"label";s:6:"Cancel";s:4:"name";s:14:"button[cancel]";}}}','size' => '','style' => '','modified' => '1321526970',);
|
||||
|
||||
$templ_data[] = array('name' => 'admin.export_users_csv_selectors','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:6:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:4:{s:4:"type";s:14:"select-account";s:4:"size";s:10:"All,groups";s:5:"label";s:5:"Group";s:4:"name";s:8:"group_id";}}}s:4:"rows";i:1;s:4:"cols";i:1;s:4:"name";s:9:"selection";s:7:"options";a:0:{}}}','size' => '','style' => '','modified' => '1302620448',);
|
||||
|
||||
$templ_data[] = array('name' => 'admin.passwordreset','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:7:{i:0;a:2:{s:2:"h1";s:6:",!@msg";s:2:"c5";s:4:",top";}i:1;a:2:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"span";s:13:"all,redItalic";s:4:"name";s:3:"msg";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:2;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:5:"label";s:12:"Select users";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:3;a:2:{s:1:"A";a:3:{s:4:"type";s:14:"select-account";s:4:"size";s:2:"15";s:4:"name";s:5:"users";}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:4;a:2:{s:1:"A";a:8:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"5";s:5:"label";s:7:"Actions";i:1;a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:21:"Set a random password";s:4:"name";s:9:"random_pw";}i:2;a:5:{s:4:"type";s:11:"select-bool";s:4:"size";s:15:"Leave unchanged";s:5:"label";s:36:"Must change password upon next login";s:4:"name";s:18:"mustchangepassword";s:8:"onchange";s:85:"if (this.value==\'1\') document.getElementById(form::name(\'changepassword\')).value=\'1\';";}i:3;a:5:{s:4:"type";s:11:"select-bool";s:4:"size";s:15:"Leave unchanged";s:5:"label";s:19:"Can change password";s:4:"name";s:14:"changepassword";s:8:"onchange";s:136:"var mustchange=document.getElementById(form::name(\'mustchangepassword\')); if (this.value==\'0\' && mustchange.value) mustchange.value=\'0\';";}i:4;a:4:{s:4:"type";s:4:"hbox";s:4:"size";s:6:"2,,0,0";i:1;a:4:{s:4:"type";s:6:"select";s:4:"size";s:15:"Leave unchanged";s:4:"name";s:4:"hash";s:5:"label";s:23:"Change password hash to";}i:2;a:5:{s:4:"type";s:4:"text";s:5:"label";s:12:"Current hash";s:4:"name";s:12:"current_hash";s:4:"span";s:14:",leftPad5 gray";s:8:"readonly";s:1:"1";}}i:5;a:3:{s:4:"type";s:8:"checkbox";s:5:"label";s:20:"Notify user by email";s:4:"name";s:6:"notify";}}s:1:"B";a:1:{s:4:"type";s:5:"label";}}i:5;a:2:{s:1:"A";a:5:{s:4:"type";s:8:"groupbox";s:4:"size";s:1:"2";s:5:"label";s:17:"Notification mail";i:1;a:4:{s:4:"type";s:4:"text";s:4:"size";s:2:"64";s:4:"name";s:7:"subject";s:4:"blur";s:7:"Subject";}i:2;a:3:{s:4:"type";s:8:"textarea";s:4:"size";s:5:"15,64";s:4:"name";s:4:"body";}}s:1:"B";a:4:{s:4:"type";s:4:"vbox";s:4:"size";s:1:"2";i:1;a:3:{s:4:"type";s:5:"label";s:4:"span";s:5:",gray";s:5:"label";s:22:"Available placeholders";}i:2;a:6:{s:4:"type";s:4:"grid";s:4:"span";s:5:",gray";s:4:"name";s:12:"replacements";s:4:"data";a:2:{i:0;a:0:{}i:1;a:2:{s:1:"A";a:2:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[name]";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:4:"name";s:13:"${row}[label]";}}}s:4:"rows";i:1;s:4:"cols";i:2;}}}i:6;a:2:{s:1:"A";a:3:{s:4:"type";s:6:"button";s:5:"label";s:5:"Start";s:4:"name";s:5:"start";}s:1:"B";a:3:{s:4:"type";s:6:"button";s:5:"label";s:12:"Download CSV";s:4:"name";s:12:"download_csv";}}}s:4:"rows";i:6;s:4:"cols";i:2;}}','size' => '','style' => '','modified' => '1301655701',);
|
||||
|
31
admin/templates/default/customtranslation.xet
Normal file
31
admin/templates/default/customtranslation.xet
Normal file
@ -0,0 +1,31 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id$ -->
|
||||
<overlay>
|
||||
<template id="admin.customtranslation" template="" lang="" group="0" version="1.9.001">
|
||||
<description id="msg" class="redItalic"/>
|
||||
<grid id="rows">
|
||||
<columns>
|
||||
<column/>
|
||||
<column/>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row class="th">
|
||||
<description value="Phrase"/>
|
||||
<description value="Translation"/>
|
||||
<description value="Action"/>
|
||||
</row>
|
||||
<row>
|
||||
<textbox id="${row}[phrase]" size="64"/>
|
||||
<textbox id="${row}[translation]" size="64"/>
|
||||
<button align="center" label="Delete" id="delete[$row]" onclick="return confirm('Delete');" image="delete"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
<hbox>
|
||||
<button label="Save" id="button[save]"/>
|
||||
<button label="Apply" id="button[apply]"/>
|
||||
<button label="Cancel" id="button[cancel]"/>
|
||||
</hbox>
|
||||
</template>
|
||||
</overlay>
|
@ -98,7 +98,7 @@ class translation
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $instance_specific_translations = array('loginscreen','mainscreen');
|
||||
static $instance_specific_translations = array('loginscreen','mainscreen','custom');
|
||||
|
||||
/**
|
||||
* returns the charset to use (!$lang) or the charset of the lang-files or $lang
|
||||
@ -188,6 +188,8 @@ class translation
|
||||
self::add_app('common');
|
||||
}
|
||||
self::add_app($GLOBALS['egw_info']['flags']['currentapp']);
|
||||
// load instance specific translations
|
||||
self::add_app('custom');
|
||||
}
|
||||
}
|
||||
|
||||
@ -252,6 +254,7 @@ class translation
|
||||
static function add_app($app,$lang=False)
|
||||
{
|
||||
$lang = $lang ? $lang : self::$userlang;
|
||||
if ($app == 'custom') $lang = 'en'; // custom translations use only 'en'
|
||||
if (!isset(self::$loaded_apps[$app]) || self::$loaded_apps[$app] != $lang)
|
||||
{
|
||||
//$start = microtime(true);
|
||||
@ -924,14 +927,16 @@ class translation
|
||||
}
|
||||
|
||||
/**
|
||||
* insert/update one phrase in the lang-table
|
||||
* insert/update/delete one phrase in the lang-table
|
||||
*
|
||||
* @param string $lang
|
||||
* @param string $app
|
||||
* @param string $message_id
|
||||
* @param string $content
|
||||
* @param string $content translation or null to delete translation
|
||||
*/
|
||||
static function write($lang,$app,$message_id,$content)
|
||||
{
|
||||
if ($content)
|
||||
{
|
||||
self::$db->insert(self::LANG_TABLE,array(
|
||||
'content' => $content,
|
||||
@ -940,7 +945,15 @@ class translation
|
||||
'app_name' => $app,
|
||||
'message_id' => $message_id,
|
||||
),__LINE__,__FILE__);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
self::$db->delete(self::LANG_TABLE,array(
|
||||
'lang' => $lang,
|
||||
'app_name' => $app,
|
||||
'message_id' => $message_id,
|
||||
),__LINE__,__FILE__);
|
||||
}
|
||||
// invalidate the cache
|
||||
if(!in_array($app,self::$instance_specific_translations))
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user