Example #1
0
 /**
  * Replace the word by the key defined in the language mapping file.
  * @param string $buffer 
  */
 public function replaceWordByKey($buffer)
 {
     preg_match_all('/(%({\\w*})({\\w*})%|%({\\w*})%)/', $buffer, $matches);
     /**
      * @TODO: Consider two level keyword like %{A}{B}% 
      */
     foreach ($matches[0] as $idx => $rawWdKey) {
         $tmpWdKey = str_replace('%{', '', $rawWdKey);
         $wdKey = str_replace('}%', '', $tmpWdKey);
         $toReplaceWord = $this->getWord($wdKey, LangReg::getLanguageCode());
         if ($toReplaceWord != "" || !is_null($toReplaceWord)) {
             $buffer = str_replace($rawWdKey, $toReplaceWord, $buffer);
         }
     }
     return $buffer;
 }