Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

Facing a culture problem

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3
View previous topic :: View next topic  
Author Message
Margodth
Smarty Rookie


Joined: 28 Mar 2004
Posts: 11

PostPosted: Mon Jan 09, 2012 11:40 pm    Post subject: Facing a culture problem Reply with quote

I'm making an app that requires different cultures.
When trying to format numbers I have to format numbers like this

Code:
{$myVar|number_format:2:".":","}


but depending on the culture it may be comma inverted.
How can I sove this without making different templates for every culture?

Thanks.
Back to top
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 5068
Location: Hamburg / Germany

PostPosted: Fri Jan 13, 2012 1:18 pm    Post subject: Reply with quote

Use variables which you assign with the corresponding "." and "," value depending on culture.
Back to top
View user's profile Send private message
rodneyrehm
Administrator


Joined: 30 Mar 2007
Posts: 674
Location: Germany, border to Switzerland

PostPosted: Fri Jan 13, 2012 1:27 pm    Post subject: Reply with quote

have a look at the php intl (internationalization) tools, specifically the NumberFormatter.
_________________
Twitter
Back to top
View user's profile Send private message Visit poster's website
Margodth
Smarty Rookie


Joined: 28 Mar 2004
Posts: 11

PostPosted: Sun Jan 15, 2012 12:25 am    Post subject: Reply with quote

While rodneyrehm solution looks nicer, U.Tews solution it's easier to implement and iterates less.
I've been trying to implement U.Tews solution before, but I mixed up some things in a not happy way.

That's the way I've solve it.
Code:

{$total|number_format:2:"{$lang.decimalchar}":"{$lang.thousandchar}"}

thanks a lot for the answers.
Back to top
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> Smarty 3 All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP