Ver código fonte

Simplify gettext

Nathaniel van Diepen 7 anos atrás
pai
commit
4018e34a12
1 arquivos alterados com 10 adições e 7 exclusões
  1. 10 7
      Data/template.class.php

+ 10 - 7
Data/template.class.php

@@ -95,14 +95,17 @@
 			}, $output);
 			// Handle {gettext}
 			$output = preg_replace_callback(static::$regex['gettext'], function($matches){
-				$output = "<?= sprintf(_(";
-				$output .= "{$matches[1]})";
-				foreach(array_slice($matches, 2) as $item){
-					if(preg_match(static::$regex['gettext_string'], $item)){
-						$output .= ", $item";
-					}else{
-						$output .= ", (\$data['{$item}'] ?? '')";
+				if(count($matches) > 2){
+					$output = "<?= sprintf(_({$matches[1]})";
+					foreach(array_slice($matches, 2) as $item){
+						if(preg_match(static::$regex['gettext_string'], $item)){
+							$output .= ", $item";
+						}else{
+							$output .= ", (\$data['{$item}'] ?? '')";
+						}
 					}
+				}else{
+					$output = "<?= _({$matches[1]})";
 				}
 				return "{$output}); ?>";
 			}, $output);