<commit_before><?php
function smarty_prefilter_tr($source) {
  // Now replace the matched language strings with the entry in the file
//  $return = preg_replace_callback('/\{tr[^\{]*\}([^\{]+)\{\/tr\}/', '_translate_lang', $source);
// correction in order to match when a variable is inside {tr} tags. Example: {tr}The newsletter was sent to {$sent} email addresses{/tr}, and where there are parameters with {tr} 
  $return = preg_replace_callback('/(\{tr[^\}]*\})(.+?)\{\/tr\}/', '_translate_lang', $source);
  return $return;
}

function _translate_lang($key) {
  global $language;
  global $lang_use_db;
  if ($lang_use_db!='y') {
    include("lang/$language/language.php");
    if(isset($lang[$key[2]]))
      if ($key[1] == "{tr}") {
        return $lang[$key[2]];// no more possible translation in block.tr.php
      }
      else {
        return $key[1].$lang[$key[2]]."{/tr}";// perhaps variable substitution to do in block.tr.php
      }
    else {
      return $key[1].$key[2]."{/tr}";// keep the tags to be perhaps translated in block.tr.php
    }
  }
   else {
    global $tikilib;
    $content = $key[2];
    $query="select tran from tiki_language where source='".addslashes($content)."' and lang='".$language."'";
    $result=$tikilib->db->query($query);
    $res=$result->fetchRow(DB_FETCHMODE_ASSOC);
    if(DB::isError($result)) { echo $content ; return; }
    if(!isset($res["tran"])) {
      global $record_untranslated;
      if ($record_untranslated=='y') {
        $query="insert into tiki_untranslated (source,lang) values('".addslashes($content)."','".$language."')";
        //No eror checking here
        $tikilib->db->query($query);
        }
      return $key[1].$content."{/tr}";
    }
    if ($key[1] == "{tr}")
        return $res["tran"];// no more possible translation in block.tr.php
     else
        return $key[1].$res["tran"]."{/tr}";// perhaps variable substituion to do in block.tr.php
  }
}
?><commit_msg>fixed odd problem of output motivated by tha lack of some curly braces<commit_after><?php
function smarty_prefilter_tr($source) {
  // Now replace the matched language strings with the entry in the file
//  $return = preg_replace_callback('/\{tr[^\{]*\}([^\{]+)\{\/tr\}/', '_translate_lang', $source);
// correction in order to match when a variable is inside {tr} tags. Example: {tr}The newsletter was sent to {$sent} email addresses{/tr}, and where there are parameters with {tr} 
  $return = preg_replace_callback('/(\{tr[^\}]*\})(.+?)\{\/tr\}/', '_translate_lang', $source);
  return $return;
}

function _translate_lang($key) {
  global $language;
  global $lang_use_db;
  if ($lang_use_db!='y') {
    include("lang/$language/language.php");
    if(isset($lang[$key[2]]))
      if ($key[1] == "{tr}") {
        return $lang[$key[2]];// no more possible translation in block.tr.php
      }
      else {
        return $key[1].$lang[$key[2]]."{/tr}";// perhaps variable substitution to do in block.tr.php
      }
    else {
      return $key[1].$key[2]."{/tr}";// keep the tags to be perhaps translated in block.tr.php
    }
  }
   else {
    global $tikilib;
    $content = $key[2];
    $query="select tran from tiki_language where source='".addslashes($content)."' and lang='".$language."'";
    $result=$tikilib->db->query($query);
    $res=$result->fetchRow(DB_FETCHMODE_ASSOC);
    if(DB::isError($result)) { echo $content ; return; }
    if(!isset($res["tran"])) {
      global $record_untranslated;
      if ($record_untranslated=='y') {
        $query="insert into tiki_untranslated (source,lang) values('".addslashes($content)."','".$language."')";
        //No eror checking here
        $tikilib->db->query($query);
      }
      return $key[1].$content."{/tr}";
    }
    if ($key[1] == "{tr}") {
      return $res["tran"];// no more possible translation in block.tr.php
    } else {
      return $key[1].$res["tran"]."{/tr}";// perhaps variable substituion to do in block.tr.php
		}
  }
}
?>
{'fraction_non_alphanumeric': 0.19929185634800203, 'fraction_numerical': 0.00556398583712696, 'mean_word_length': 3.3271334792122538, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3493597', 'n_tokens_mistral': 1337, 'n_tokens_neox': 1316, 'n_words': 318}