From 4f91e14cab27d53d0dcb7ee0cdbe7d33c927fdd8 Mon Sep 17 00:00:00 2001 From: Marlin Cremers Date: Sun, 8 Jun 2014 13:41:48 +0200 Subject: [PATCH] Refactor translation functions arguments handeling --- lib/Cake/I18n/I18n.php | 20 ++++++++++++ lib/Cake/basics.php | 70 +++++++++--------------------------------- 2 files changed, 34 insertions(+), 56 deletions(-) diff --git a/lib/Cake/I18n/I18n.php b/lib/Cake/I18n/I18n.php index 16fb9983d..43cb4b1d5 100644 --- a/lib/Cake/I18n/I18n.php +++ b/lib/Cake/I18n/I18n.php @@ -643,6 +643,26 @@ class I18n { return $definitions; } +/** + * Puts the parameters in raw translated strings + * + * @param string $translated The raw translated string + * @param array $args The arguments to put in the translation + * @return string Translated string with arguments + */ + public static function insertArgs($translated, array $args) { + if (empty($args)) { + return $translated; + } + + if (is_array($args[0])) { + $args = $args[0]; + } + + $translated = preg_replace('/(?