|
From: Florin C B. <ory...@us...> - 2013-04-05 05:07:52
|
Update of /cvsroot/mxbb/core/includes In directory sfp-cvs-1.v30.ch3.sourceforge.com:/tmp/cvs-serv2583 Modified Files: mx_functions.php Log Message: function t() for translation and compatibility with the calendar module features common with other CMS systems. Index: mx_functions.php =================================================================== RCS file: /cvsroot/mxbb/core/includes/mx_functions.php,v retrieving revision 1.109 retrieving revision 1.110 diff -C2 -d -r1.109 -r1.110 *** mx_functions.php 8 Oct 2012 09:05:08 -0000 1.109 --- mx_functions.php 5 Apr 2013 05:07:49 -0000 1.110 *************** *** 2662,2665 **** --- 2662,2708 ---- /** + * function t + * temp replacement for t() + * We provide for a possible localization function, t(). + * + */ + function t($string, array $args = array(), array $options = array()) + { + global $lang; + static $custom_strings; + + // Merge in default. + if (empty($options['langcode'])) { + $options['langcode'] = $lang['USER_LANG'] ? $lang['USER_LANG'] : $mx_user->encode_lang($board_config['default_lang']); + } + if (empty($options['context'])) { + $options['context'] = ''; + } + + // First, check for an array of customized strings. If present, use the array + // *instead of* database lookups. + // Cache the $custom_strings variable to improve performance. + if (!isset($custom_strings[$options['langcode']])) + { + $custom_strings[$options['langcode']] = variable_get('locale_custom_strings_' . $options['langcode'], array()); + } + + // Custom strings work for English. + if (isset($custom_strings[$options['langcode']][$options['context']][$string])) + { + $string = $custom_strings[$options['langcode']][$options['context']][$string]; + } + + if (empty($args)) + { + return $string; + } + else + { + return format_string($string, $args); + } + } + + /** * function eregi * |