Ticket #569: 569-jLocale-support-multiline-rendering-in-strings.diff

File 569-jLocale-support-multiline-rendering-in-strings.diff, 1.5 kB (added by Julien, 4 months ago)

patch for handling \n in strings and getting <br /> tags with html jlocale plugin for jtpl

  • lib/jelix/plugins/tpl/html/function.jlocale.php

    old new  
    2020{ 
    2121     if(func_num_args() == 3 && is_array(func_get_arg(2))){ 
    2222         $param = func_get_arg(2); 
    23          echo htmlspecialchars(jLocale::get($locale, $param)); 
     23         echo nl2br(htmlspecialchars(jLocale::get($locale, $param))); 
    2424     }elseif(func_num_args() > 2){ 
    2525         $params = func_get_args(); 
    2626         unset($params[0]); 
    2727         unset($params[1]); 
    28          echo htmlspecialchars(jLocale::get($locale, $params)); 
     28         echo nl2br(htmlspecialchars(jLocale::get($locale, $params))); 
    2929     }else{ 
    30          echo htmlspecialchars(jLocale::get($locale)); 
     30         echo nl2br(htmlspecialchars(jLocale::get($locale))); 
    3131     } 
    3232} 
    3333 
  • lib/jelix/core/jLocale.class.php

    old new  
    227227            } 
    228228            return jLocale::get ($key, $args, $gJConfig->locale); 
    229229        }else{ 
     230            $string = str_replace('\n',"\n",$string); 
    230231            //here, we know the message 
    231232            if ($args!==null){ 
    232233                $string = call_user_func_array('sprintf', array_merge (array ($string), is_array ($args) ? $args : array ($args))); 
Download in other formats: Original Format