[Vtigercrm-commits] [Vtiger development] #8163: cache translations
Vtiger development
vtiger-tickets at trac.vtiger.com
Tue Jul 22 13:00:56 GMT 2014
#8163: cache translations
------------------------+------------------------
Reporter: alanbell | Owner: developer
Type: defect | Status: new
Priority: unassigned | Milestone: Unassigned
Component: vtigercrm | Version: 6.0.0
Severity: Medium | Keywords:
------------------------+------------------------
the vtranslate function in includes/runtime/LanguageHandler could cache
the values it looks up, using the Vtiger_cache infrastructure means this
works well with a persistent cache.
Index: includes/runtime/LanguageHandler.php
===================================================================
--- includes/runtime/LanguageHandler.php (revision 14165)
+++ includes/runtime/LanguageHandler.php (working copy)
@@ -251,12 +251,17 @@
}
function vtranslate($key, $moduleName = '') {
- $args = func_get_args();
- $formattedString =
call_user_func_array(array('Vtiger_Language_Handler',
'getTranslatedString'), $args);
- array_shift($args);
- array_shift($args);
- if (is_array($args) && !empty($args)) {
+ $cache = Vtiger_Cache::getInstance();
+ $formattedString=$cache->get("translation",$moduleName.$key);
+ if(!$formattedString){
+ $args = func_get_args();
+ $formattedString =
call_user_func_array(array('Vtiger_Language_Handler',
'getTranslatedString'), $args);
+ array_shift($args);
+ array_shift($args);
+ if (is_array($args) && !empty($args)) {
$formattedString = call_user_func_array('vsprintf',
array($formattedString, $args));
+ }
+ $cache->set("translation",$moduleName.$key,$formattedString);
}
return $formattedString;
}
--
Ticket URL: <http://trac.vtiger.com/cgi-bin/trac.cgi/ticket/8163>
Vtiger development <http://trac.vtiger.com/>
Vtiger CRM
More information about the vtigercrm-commits
mailing list