Skip to content

Commit

Permalink
Issue with sent mails
Browse files Browse the repository at this point in the history
  • Loading branch information
jjrom committed Jun 4, 2015
1 parent bcf17b9 commit fb7ed32
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 30 deletions.
15 changes: 14 additions & 1 deletion include/resto/RestoDictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,20 @@ public function isStopWord($name) {
* @param string any number of optional arguments
*/
public function translate($sentence) {
return RestoUtil::replaceInTemplate(isset($this->translations) && isset($this->translations[$sentence]) ? $this->translations[$sentence] : $sentence);
if (isset($this->translations) && isset($this->translations[$sentence])) {
$sentence = $this->translations[$sentence];
}

if (false !== strpos($sentence, '{a:')) {
$replace = array();
$args = func_get_args();
for ($i = 1, $max = count($args); $i < $max; $i++) {
$replace['{a:' . $i . '}'] = $args[$i];
}

return strtr($sentence, $replace);
}
return $sentence;
}


Expand Down
29 changes: 0 additions & 29 deletions include/resto/Utils/RestoUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -481,35 +481,6 @@ public static function queryStringToKvps($queryString) {
return $output;
}

/**
* Replace {a:x} in sentence
*
* Example :
*
* 'Hello. My name is {a:1}. I live in {a:2}'
*
* Call to RestoUtil::replaceInTemplate('presentation', 'Jérôme', 'Toulouse');
* Will return
*
* 'Hello. My name is Jérôme. I live in Toulouse
*
*
* @param string $name
* @param string any number of optional arguments
*/
public function replaceInTemplate($sentence) {
if (false !== strpos($sentence, '{a:')) {
$replace = array();
$args = func_get_args();
for ($i = 1, $max = count($args); $i < $max; $i++) {
$replace['{a:' . $i . '}'] = $args[$i];
}

return strtr($sentence, $replace);
}
return $sentence;
}

/**
* Pretty print a json string
* Code from https://github.com/ryanuber/projects/blob/master/PHP/JSON/jsonpp.php
Expand Down

0 comments on commit fb7ed32

Please sign in to comment.