Skip to content
This repository
Browse code

BUGFIX Fail silently in _t() legacy mode when using sprintf(), to avo…

…id outdated translations breaking with a fatal error (e.g. CMSMain.ACCESS changed from two to one usage of {title}, which isn't changed yet in most languages). Slight performance overhead, but acceptable since its legacy usage only
  • Loading branch information...
commit acfc658b4e6ffa422771fbc019435471dc6a60c3 1 parent 69d3497
Ingo Schommer authored June 04, 2012

Showing 1 changed file with 3 additions and 1 deletion. Show diff stats Hide diff stats

  1. 4  i18n/i18n.php
4  i18n/i18n.php
@@ -1524,7 +1524,9 @@ static function _t($entity, $string = "", $context = "", $injection = "") {
1524 1524
 			if(!preg_match($regex, $returnValue)) {
1525 1525
 				// Legacy mode: If no injection placeholders are found, 
1526 1526
 				// replace sprintf placeholders in fixed order.
1527  
-				$returnValue = vsprintf($returnValue, array_values($injectionArray));
  1527
+				// Fail silently in case the translation is outdated
  1528
+				$replaced = @vsprintf($returnValue, array_values($injectionArray));	
  1529
+				if($replaced) $returnValue = $replaced;
1528 1530
 			} else if(!ArrayLib::is_associative($injectionArray)) {
1529 1531
 				// Legacy mode: If injection placeholders are found,
1530 1532
 				// but parameters are passed without names, replace them in fixed order.

0 notes on commit acfc658

Please sign in to comment.
Something went wrong with that request. Please try again.