is not used any more and exists only for history. Post new tickets on the Github account. n'est plus utilisée, et existe uniquement pour son historique. Postez les nouveaux tickets sur le compte github.

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#1150 closed bug (fixed)

jTpl: number_format modifier should use non-breakable spaces

Reported by: Julien Owned by: Julien
Priority: normal Milestone: Jelix 1.2RC1
Component: jelix:core:jLocale Version: trunk
Severity: normal Keywords:
Cc: Blocked By:
Blocking: Documentation needed: no
Hosting Provider: Php version:


Change History (7)

comment:1 Changed 11 years ago by Julien

  • review set to review?
  • Status changed from new to assigned

comment:2 Changed 11 years ago by laurentj

  • Component changed from jelix:plugins:tpl to jelix:core:jLocale
  • Documentation needed set
  • Resolution set to fixed
  • review review? deleted
  • Status changed from assigned to closed

It's better to fix the issue at the origin ;-)

The default format for thousands_sep should be a non breakable space. In order to do that, a new escaped character should be supported in properties file. I choose "\S" to generate a non breakable space.

comment:3 Changed 11 years ago by Julien

  • Resolution fixed deleted
  • Status changed from closed to reopened

well, in fact it doesn't work, due to some php limitation: only the first char of the thousands separator is used :(


I propose to keep your approach, as unbreakable spaces may be needed elsewhere, and to change the plugin to something like this :

function jtpl_modifier_common_number_format($number, $decimals=0, $dec_point=false, $thousands_sep=false){
    if ($dec_point == false) {
        $dec_point = jLocale::get('jelix~format.decimal_point');
    if ($thousands_sep === false) {
        $thousands_sep = jLocale::get('jelix~format.thousands_sep');
        if(strlen($thousands_sep) > 1){
            $real_thousands_sep = $thousands_sep;
            $thousands_sep = '#';
    $number = number_format($number, $decimals, $dec_point, $thousands_sep);
        return str_replace($thousands_sep, $real_thousands_sep, $number);
    return $number;

what I'm doing here is to check if the separator is greater than 1 char (in ascii) and if so, replace it by an other char (# here, maybe we need another less used one) then finally replace with the good one.

comment:6 Changed 11 years ago by laurentj

  • Resolution set to fixed
  • review changed from review? to review+
  • Status changed from reopened to closed
Note: See TracTickets for help on using tickets.