Changeset 953

Show
Ignore:
Timestamp:
05/28/08 13:42:04 (6 months ago)
Author:
julieni
Message:

ticket #569: jLocale : support multiline rendering in strings

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/build/manifests/testapp.mn

    r939 r953  
    111111  tests1.UTF-8.properties 
    112112  tests3.UTF-8.properties 
     113  tests4.UTF-8.properties 
    113114cd testapp/modules/jelix_tests/templates 
    114115  menu.tpl 
  • trunk/build/manifests/testapp.mn

    r939 r953  
    111111  tests1.UTF-8.properties 
    112112  tests3.UTF-8.properties 
     113  tests4.UTF-8.properties 
    113114cd testapp/modules/jelix_tests/templates 
    114115  menu.tpl 
  • trunk/build/manifests/testapp.mn

    r939 r953  
    111111  tests1.UTF-8.properties 
    112112  tests3.UTF-8.properties 
     113  tests4.UTF-8.properties 
    113114cd testapp/modules/jelix_tests/templates 
    114115  menu.tpl 
  • trunk/build/manifests/testapp.mn

    r939 r953  
    111111  tests1.UTF-8.properties 
    112112  tests3.UTF-8.properties 
     113  tests4.UTF-8.properties 
    113114cd testapp/modules/jelix_tests/templates 
    114115  menu.tpl 
  • trunk/lib/jelix/core/jLocale.class.php

    r803 r953  
    55* @author     Laurent Jouanneau 
    66* @author     Gerald Croes 
    7 * @contributor 
     7* @contributor Julien Issler 
    88* @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau 
    99* Some parts of this file are took from Copix Framework v2.3dev20050901, CopixI18N.class.php, http://www.copix.org. 
     
    1111* initial authors : Gerald Croes, Laurent Jouanneau. 
    1212* enhancement by Laurent Jouanneau for Jelix. 
     13* @copyright 2008 Julien Issler 
    1314* @link        http://www.jelix.org 
    1415* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    121122                            $sp = preg_split('/(?<!\\\\)\#/', $match[1], -1 ,PREG_SPLIT_NO_EMPTY); 
    122123                            $multiline= ($match[2] =="\\"); 
    123                             $this->_strings[$charset][$key].=' '.trim(str_replace('\#','#',$sp[0])); 
     124                            $this->_strings[$charset][$key].=' '.trim(str_replace(array('\#','\n'),array('#',"\n"),$sp[0])); 
    124125                        }else{ 
    125126                            throw new Exception('Syntaxe error in file properties '.$fichier.' line '.$linenumber,210); 
     
    139140                        } 
    140141 
    141                         $this->_strings[$charset][$key] =$value
     142                        $this->_strings[$charset][$key] = str_replace(array('\#','\n'),array('#',"\n"),$value)
    142143 
    143144                    }elseif(preg_match("/^\s*(\#.*)?$/",$line, $match)){ 
  • trunk/lib/jelix/core/jLocale.class.php

    r803 r953  
    55* @author     Laurent Jouanneau 
    66* @author     Gerald Croes 
    7 * @contributor 
     7* @contributor Julien Issler 
    88* @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau 
    99* Some parts of this file are took from Copix Framework v2.3dev20050901, CopixI18N.class.php, http://www.copix.org. 
     
    1111* initial authors : Gerald Croes, Laurent Jouanneau. 
    1212* enhancement by Laurent Jouanneau for Jelix. 
     13* @copyright 2008 Julien Issler 
    1314* @link        http://www.jelix.org 
    1415* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    121122                            $sp = preg_split('/(?<!\\\\)\#/', $match[1], -1 ,PREG_SPLIT_NO_EMPTY); 
    122123                            $multiline= ($match[2] =="\\"); 
    123                             $this->_strings[$charset][$key].=' '.trim(str_replace('\#','#',$sp[0])); 
     124                            $this->_strings[$charset][$key].=' '.trim(str_replace(array('\#','\n'),array('#',"\n"),$sp[0])); 
    124125                        }else{ 
    125126                            throw new Exception('Syntaxe error in file properties '.$fichier.' line '.$linenumber,210); 
     
    139140                        } 
    140141 
    141                         $this->_strings[$charset][$key] =$value
     142                        $this->_strings[$charset][$key] = str_replace(array('\#','\n'),array('#',"\n"),$value)
    142143 
    143144                    }elseif(preg_match("/^\s*(\#.*)?$/",$line, $match)){ 
  • trunk/lib/jelix/core/jLocale.class.php

    r803 r953  
    55* @author     Laurent Jouanneau 
    66* @author     Gerald Croes 
    7 * @contributor 
     7* @contributor Julien Issler 
    88* @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau 
    99* Some parts of this file are took from Copix Framework v2.3dev20050901, CopixI18N.class.php, http://www.copix.org. 
     
    1111* initial authors : Gerald Croes, Laurent Jouanneau. 
    1212* enhancement by Laurent Jouanneau for Jelix. 
     13* @copyright 2008 Julien Issler 
    1314* @link        http://www.jelix.org 
    1415* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    121122                            $sp = preg_split('/(?<!\\\\)\#/', $match[1], -1 ,PREG_SPLIT_NO_EMPTY); 
    122123                            $multiline= ($match[2] =="\\"); 
    123                             $this->_strings[$charset][$key].=' '.trim(str_replace('\#','#',$sp[0])); 
     124                            $this->_strings[$charset][$key].=' '.trim(str_replace(array('\#','\n'),array('#',"\n"),$sp[0])); 
    124125                        }else{ 
    125126                            throw new Exception('Syntaxe error in file properties '.$fichier.' line '.$linenumber,210); 
     
    139140                        } 
    140141 
    141                         $this->_strings[$charset][$key] =$value
     142                        $this->_strings[$charset][$key] = str_replace(array('\#','\n'),array('#',"\n"),$value)
    142143 
    143144                    }elseif(preg_match("/^\s*(\#.*)?$/",$line, $match)){ 
  • trunk/lib/jelix/core/jLocale.class.php

    r803 r953  
    55* @author     Laurent Jouanneau 
    66* @author     Gerald Croes 
    7 * @contributor 
     7* @contributor Julien Issler 
    88* @copyright  2001-2005 CopixTeam, 2005-2007 Laurent Jouanneau 
    99* Some parts of this file are took from Copix Framework v2.3dev20050901, CopixI18N.class.php, http://www.copix.org. 
     
    1111* initial authors : Gerald Croes, Laurent Jouanneau. 
    1212* enhancement by Laurent Jouanneau for Jelix. 
     13* @copyright 2008 Julien Issler 
    1314* @link        http://www.jelix.org 
    1415* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    121122                            $sp = preg_split('/(?<!\\\\)\#/', $match[1], -1 ,PREG_SPLIT_NO_EMPTY); 
    122123                            $multiline= ($match[2] =="\\"); 
    123                             $this->_strings[$charset][$key].=' '.trim(str_replace('\#','#',$sp[0])); 
     124                            $this->_strings[$charset][$key].=' '.trim(str_replace(array('\#','\n'),array('#',"\n"),$sp[0])); 
    124125                        }else{ 
    125126                            throw new Exception('Syntaxe error in file properties '.$fichier.' line '.$linenumber,210); 
     
    139140                        } 
    140141 
    141                         $this->_strings[$charset][$key] =$value
     142                        $this->_strings[$charset][$key] = str_replace(array('\#','\n'),array('#',"\n"),$value)
    142143 
    143144                    }elseif(preg_match("/^\s*(\#.*)?$/",$line, $match)){ 
  • trunk/lib/jelix/CREDITS

    r951 r953  
    2424 - jZipCreator : empty dirs are not included in the archive (#570) 
    2525 - jForms : fixed bugs in jforms.js based on Martus' report (#554) 
     26 - jLocale : support multiline rendering in strings (#569) 
    2627 
    2728Bastien Jaillot (aka bastnic) 
  • trunk/lib/jelix/CREDITS

    r951 r953  
    2424 - jZipCreator : empty dirs are not included in the archive (#570) 
    2525 - jForms : fixed bugs in jforms.js based on Martus' report (#554) 
     26 - jLocale : support multiline rendering in strings (#569) 
    2627 
    2728Bastien Jaillot (aka bastnic) 
  • trunk/lib/jelix/CREDITS

    r951 r953  
    2424 - jZipCreator : empty dirs are not included in the archive (#570) 
    2525 - jForms : fixed bugs in jforms.js based on Martus' report (#554) 
     26 - jLocale : support multiline rendering in strings (#569) 
    2627 
    2728Bastien Jaillot (aka bastnic) 
  • trunk/lib/jelix/CREDITS

    r951 r953  
    2424 - jZipCreator : empty dirs are not included in the archive (#570) 
    2525 - jForms : fixed bugs in jforms.js based on Martus' report (#554) 
     26 - jLocale : support multiline rendering in strings (#569) 
    2627 
    2728Bastien Jaillot (aka bastnic) 
  • trunk/lib/jelix/plugins/tpl/html/function.jlocale.php

    r506 r953  
    44* @subpackage jtpl_plugin 
    55* @author     Jouanneau Laurent 
    6 * @contributor 
     6* @contributor Julien Issler 
    77* @copyright  2005-2007 Jouanneau laurent 
     8* @copyright 2008 Julien Issler 
    89* @link        http://www.jelix.org 
    910* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    2122     if(func_num_args() == 3 && is_array(func_get_arg(2))){ 
    2223         $param = func_get_arg(2); 
    23          echo htmlspecialchars(jLocale::get($locale, $param)); 
     24         echo nl2br(htmlspecialchars(jLocale::get($locale, $param))); 
    2425     }elseif(func_num_args() > 2){ 
    2526         $params = func_get_args(); 
    2627         unset($params[0]); 
    2728         unset($params[1]); 
    28          echo htmlspecialchars(jLocale::get($locale, $params)); 
     29         echo nl2br(htmlspecialchars(jLocale::get($locale, $params))); 
    2930     }else{ 
    30          echo htmlspecialchars(jLocale::get($locale)); 
     31         echo nl2br(htmlspecialchars(jLocale::get($locale))); 
    3132     } 
    3233} 
  • trunk/lib/jelix/plugins/tpl/html/function.jlocale.php

    r506 r953  
    44* @subpackage jtpl_plugin 
    55* @author     Jouanneau Laurent 
    6 * @contributor 
     6* @contributor Julien Issler 
    77* @copyright  2005-2007 Jouanneau laurent 
     8* @copyright 2008 Julien Issler 
    89* @link        http://www.jelix.org 
    910* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    2122     if(func_num_args() == 3 && is_array(func_get_arg(2))){ 
    2223         $param = func_get_arg(2); 
    23          echo htmlspecialchars(jLocale::get($locale, $param)); 
     24         echo nl2br(htmlspecialchars(jLocale::get($locale, $param))); 
    2425     }elseif(func_num_args() > 2){ 
    2526         $params = func_get_args(); 
    2627         unset($params[0]); 
    2728         unset($params[1]); 
    28          echo htmlspecialchars(jLocale::get($locale, $params)); 
     29         echo nl2br(htmlspecialchars(jLocale::get($locale, $params))); 
    2930     }else{ 
    30          echo htmlspecialchars(jLocale::get($locale)); 
     31         echo nl2br(htmlspecialchars(jLocale::get($locale))); 
    3132     } 
    3233} 
  • trunk/lib/jelix/plugins/tpl/html/function.jlocale.php

    r506 r953  
    44* @subpackage jtpl_plugin 
    55* @author     Jouanneau Laurent 
    6 * @contributor 
     6* @contributor Julien Issler 
    77* @copyright  2005-2007 Jouanneau laurent 
     8* @copyright 2008 Julien Issler 
    89* @link        http://www.jelix.org 
    910* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    2122     if(func_num_args() == 3 && is_array(func_get_arg(2))){ 
    2223         $param = func_get_arg(2); 
    23          echo htmlspecialchars(jLocale::get($locale, $param)); 
     24         echo nl2br(htmlspecialchars(jLocale::get($locale, $param))); 
    2425     }elseif(func_num_args() > 2){ 
    2526         $params = func_get_args(); 
    2627         unset($params[0]); 
    2728         unset($params[1]); 
    28          echo htmlspecialchars(jLocale::get($locale, $params)); 
     29         echo nl2br(htmlspecialchars(jLocale::get($locale, $params))); 
    2930     }else{ 
    30          echo htmlspecialchars(jLocale::get($locale)); 
     31         echo nl2br(htmlspecialchars(jLocale::get($locale))); 
    3132     } 
    3233} 
  • trunk/lib/jelix/plugins/tpl/html/function.jlocale.php

    r506 r953  
    44* @subpackage jtpl_plugin 
    55* @author     Jouanneau Laurent 
    6 * @contributor 
     6* @contributor Julien Issler 
    77* @copyright  2005-2007 Jouanneau laurent 
     8* @copyright 2008 Julien Issler 
    89* @link        http://www.jelix.org 
    910* @licence    GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    2122     if(func_num_args() == 3 && is_array(func_get_arg(2))){ 
    2223         $param = func_get_arg(2); 
    23          echo htmlspecialchars(jLocale::get($locale, $param)); 
     24         echo nl2br(htmlspecialchars(jLocale::get($locale, $param))); 
    2425     }elseif(func_num_args() > 2){ 
    2526         $params = func_get_args(); 
    2627         unset($params[0]); 
    2728         unset($params[1]); 
    28          echo htmlspecialchars(jLocale::get($locale, $params)); 
     29         echo nl2br(htmlspecialchars(jLocale::get($locale, $params))); 
    2930     }else{ 
    30          echo htmlspecialchars(jLocale::get($locale)); 
     31         echo nl2br(htmlspecialchars(jLocale::get($locale))); 
    3132     } 
    3233} 
  • trunk/testapp/modules/jelix_tests/tests/core.jlocale.html_cli.php

    r915 r953  
    179179        $GLOBALS['gJConfig']->charset = 'UTF-8'; 
    180180    } 
    181  
     181     
     182    function testLineBreak(){ 
     183        $this->assertEqual("This sentence has a line break\n after the word \"break\"",jLocale::get('tests4.string.with.line.break',null,'en_EN','UTF-8')); 
     184    } 
     185     
     186    function testLineBreakWithMultiLineString(){ 
     187        $this->assertEqual("This multiline sentence\n has two line breaks\n after the words \"sentence\" and \"breaks\"",jLocale::get('tests4.multiline.string.with.line.break',null,'en_EN','UTF-8')); 
     188    } 
     189     
    182190} 
    183191 
  • trunk/testapp/modules/jelix_tests/tests/core.jlocale.html_cli.php

    r915 r953  
    179179        $GLOBALS['gJConfig']->charset = 'UTF-8'; 
    180180    } 
    181  
     181     
     182    function testLineBreak(){ 
     183        $this->assertEqual("This sentence has a line break\n after the word \"break\"",jLocale::get('tests4.string.with.line.break',null,'en_EN','UTF-8')); 
     184    } 
     185     
     186    function testLineBreakWithMultiLineString(){ 
     187        $this->assertEqual("This multiline sentence\n has two line breaks\n after the words \"sentence\" and \"breaks\"",jLocale::get('tests4.multiline.string.with.line.break',null,'en_EN','UTF-8')); 
     188    } 
     189     
    182190} 
    183191 
  • trunk/testapp/modules/jelix_tests/tests/core.jlocale.html_cli.php

    r915 r953  
    179179        $GLOBALS['gJConfig']->charset = 'UTF-8'; 
    180180    } 
    181  
     181     
     182    function testLineBreak(){ 
     183        $this->assertEqual("This sentence has a line break\n after the word \"break\"",jLocale::get('tests4.string.with.line.break',null,'en_EN','UTF-8')); 
     184    } 
     185     
     186    function testLineBreakWithMultiLineString(){ 
     187        $this->assertEqual("This multiline sentence\n has two line breaks\n after the words \"sentence\" and \"breaks\"",jLocale::get('tests4.multiline.string.with.line.break',null,'en_EN','UTF-8')); 
     188    } 
     189     
    182190} 
    183191 
  • trunk/testapp/modules/jelix_tests/tests/core.jlocale.html_cli.php

    r915 r953  
    179179        $GLOBALS['gJConfig']->charset = 'UTF-8'; 
    180180    } 
    181  
     181     
     182    function testLineBreak(){ 
     183        $this->assertEqual("This sentence has a line break\n after the word \"break\"",jLocale::get('tests4.string.with.line.break',null,'en_EN','UTF-8')); 
     184    } 
     185     
     186    function testLineBreakWithMultiLineString(){ 
     187        $this->assertEqual("This multiline sentence\n has two line breaks\n after the words \"sentence\" and \"breaks\"",jLocale::get('tests4.multiline.string.with.line.break',null,'en_EN','UTF-8')); 
     188    } 
     189     
    182190} 
    183191 
Download in other formats: Unified Diff Zip Archive