Yii Framework Forum: Define 'currencyFormat' in config file - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

Define 'currencyFormat' in config file Rate Topic: -----

#1 User is offline   chuntley 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 23-April 10

Posted 07 January 2011 - 04:33 PM

The current version does not seem to have any way to define a global currency format, instead, we have to define it every time a piece of currency is outputted.

I believe it would make sense to define the locale once in the config file, then all other locale-related functions will automatically convert based on that defined locale.
0

#2 User is offline   qwerty 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 315
  • Joined: 20-November 08

Posted 08 January 2011 - 03:07 AM

Try this formatCurrency
0

#3 User is offline   chuntley 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 23-April 10

Posted 08 January 2011 - 10:00 AM

View Postqwerty, on 08 January 2011 - 03:07 AM, said:

Try this formatCurrency


That works, but you have to define the type of currency on every instance you use it.
0

#4 User is offline   qwerty 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 315
  • Joined: 20-November 08

Posted 08 January 2011 - 11:25 AM

You can extend CNumberFormatter and modify this method.
0

#5 User is offline   chuntley 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 69
  • Joined: 23-April 10

Posted 08 January 2011 - 12:52 PM

View Postqwerty, on 08 January 2011 - 11:25 AM, said:

You can extend CNumberFormatter and modify this method.


Alright I can do that.

I believe this should be put into consideration for future Yii releases. As I said before, if you are going to display the language in en_US, you will probably want the currency defined there as well.
2

#6 User is offline   sitamet 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 08-October 12

Posted 17 March 2013 - 07:00 AM

Hi,
I've tried to extend CNumberFormatter but i did not succeded :(
Perhaps can't be extended as a common component?

Did you successfuly extended CNumberFormatter?
How?,
Where?
When?
0

#7 User is offline   yugene 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 515
  • Joined: 08-August 09

Posted 18 March 2013 - 06:24 AM

Hi Chuntley,

Yes, CNumberFormatter may be tricky to extend - cause of private properties, though I needed not formatCurrency() updates.
I'm extending CNumberFormatter putting NumberFormatter class to components directory and having probably all the parent class code copied into a child. It's kinda ugly solution, but I couldn't find the better one for my needs yet.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users