summaryrefslogtreecommitdiff
path: root/liberty_plugins/data.tr.php
blob: 78128b2430d8902127afed56cef4446dd7d69f4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
 * tr translation plugin
 *
 * @author     wjames5 will@tekimaki.com 
 * @version    $Revision$
 * @package    liberty
 * @subpackage plugins_data
 * @copyright  Copyright (c) 2008, bitweaver.org
 */

/**
 * Setup Code
 */
define( 'PLUGIN_GUID_DATATR', 'datatr' );
global $gLibertySystem;
$pluginParams = array (
	'tag'           => 'tr',
	'auto_activate' => FALSE,
	'requires_pair' => TRUE,
	'load_function' => 'data_tr',
	'title'         => 'Translate',
	'help_page'     => 'DataPluginTR',
	'description'   => tra( "Use this plugin to mark strings for translation. You should only use this for common short strings, and not entire pages." ),
	'help_function' => 'data_tr_help',
	'syntax'        => "{tr}",
	'plugin_type'   => DATA_PLUGIN
);
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATATR, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATATR );

function data_tr_help() {
	$help = tra( "Example: " ) . "{tr}string of text to be translated{/tr}";
	return $help;
}

function data_tr( $pData, $pParams, $pCommonObject ) {
	$transString = tra( $pData );
	$parseHash = $pCommonObject->mInfo;
	$parseHash['no_cache'] = TRUE;
	$parseHash['data'] = $transString;
	$parsedData = $pCommonObject->parseData( $parseHash );
	$parsedData = preg_replace( '|<br\s*/?>$|', '', $parsedData );
	return $parsedData;
}
?>