Development

#2161 (sfMessageFormat->formatString() fail when input is not a string)

You must first sign up to be able to contribute.

Ticket #2161 (closed defect: fixed)

Opened 1 year ago

Last modified 5 months ago

sfMessageFormat->formatString() fail when input is not a string

Reported by: tohenk Assigned to: fabien
Priority: minor Milestone: 1.0.17
Component: i18n Version: 1.0.0
Keywords: Cc:
Qualification: Unreviewed

Description

Normally, I18N function __() accept string parameter, but if we pass it a parameter of type integer (or float) and we have translation like this:

1 minute -> 1 menit

This will fail because of PHP when compare integer and string using equal (==), string will be converted to integer (or float) first.

  <?php echo __('1') // correct ?>
  <?php $test = 1 ?>
  <?php echo __($test) // -> 1 menit, should 1 ?>

Workarround is, first use identical (===) comparison in sfMessageFormat->formatString(), second, cast variable $string into string ($string = (string) $string).

Here, I included a unit test.

Attachments

sfMessageFormatTest.zip (0.9 kB) - added by tohenk on 09/01/07 07:25:59.
Test Case

Change History

09/01/07 07:25:59 changed by tohenk

  • attachment sfMessageFormatTest.zip added.

Test Case

05/22/08 10:08:05 changed by FabianLange

  • status changed from new to closed.
  • resolution set to fixed.

(In [9177]) 1.0: backported fix from r8926. fixes #2161

05/22/08 10:09:33 changed by FabianLange

(In [9178]) 1.1: added test for #2161, which was solved as side effect in r8926. refs #2161

05/22/08 10:09:51 changed by FabianLange

  • qualification set to Unreviewed.
  • milestone set to 1.0.17.