diff options
author | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-05-04 08:32:00 +0000 |
---|---|---|
committer | Gábor Hojtsy <gabor@hojtsy.hu> | 2007-05-04 08:32:00 +0000 |
commit | f0b273a9656faf9a523c670e08a7b633a294c3cd (patch) | |
tree | 1ddb717012dcf6150c5426317edf2fff08c90f74 | |
parent | 8f36367d4aa2ff2815e9d4099dc0e31916f56ce9 (diff) | |
download | brdo-f0b273a9656faf9a523c670e08a7b633a294c3cd.tar.gz brdo-f0b273a9656faf9a523c670e08a7b633a294c3cd.tar.bz2 |
#131061: Very fast t() for a small set of strings,
by Moshe Weitzman, webernet, chx, erdemkose and myself
-rw-r--r-- | includes/common.inc | 16 | ||||
-rw-r--r-- | sites/default/settings.php | 13 |
2 files changed, 28 insertions, 1 deletions
diff --git a/includes/common.inc b/includes/common.inc index 07998d416..354eb4f7f 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -700,7 +700,21 @@ function fix_gpc_magic() { */ function t($string, $args = 0) { global $language; - if (function_exists('locale') && $language->language != 'en') { + static $custom_strings; + + // First, check for an array of customized strings. If present, use the array + // *instead of* database lookups. This is a high performance way to provide a + // handful of string replacements. See settings.php for examples. + // Cache the $custom_strings variable to improve performance. + if (!isset($custom_strings)) { + $custom_strings = variable_get('locale_custom_strings_'. $language->language, array()); + } + // Custom strings work for English too, even if locale module is disabled. + if (isset($custom_strings[$string])) { + $string = $custom_strings[$string]; + } + // Translate with locale module if enabled. + elseif (function_exists('locale') && $language->language != 'en') { $string = locale($string); } if (!$args) { diff --git a/sites/default/settings.php b/sites/default/settings.php index a418a8a6b..f0289e945 100644 --- a/sites/default/settings.php +++ b/sites/default/settings.php @@ -164,3 +164,16 @@ ini_set('url_rewriter.tags', ''); # 'anonymous' => 'Visitor', # ); +/** + * String overrides: + * + * To override specific strings on your site with or without enabling locale + * module, add an entry to this list. This functionality allows you to change + * a small number of your site's default English language interface strings. + * + * Remove the leading hash signs to enable. + */ +# $conf['locale_custom_strings_en'] = array( +# 'forum' => 'Discussion board', +# '@count min' => '@count minutes', +# ); |