What is the best way to convert a currency string 'USD' to locale :en-US?
75 views
Skip to first unread message
Fai Wong
unread,
Sep 24, 2013, 10:55:09 AM9/24/13
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
What is the best way to convert a currency string 'USD' to locale :en-US? Right now trying to make it flexible to show the money and symbol correctly based on the currency string (like 'USD' or 'AUD') stored against the user's record.
I need to be able to do the following based on say 'GBP' string:
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
You could make a helper that would extract this value from the user and translate the display string. If you set up a hash like {'USD' => :en-US, 'GBP' => :en-BG, ...} then there would be one place to look for the correct symbol.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
Hang on do you mean to convert USD 1000 into AUD 1000? Surely you would need to do a currency conversion because USD 1000 is AUD 1064. This would seem to have nothing to do with locales at all.
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to rubyonra...@googlegroups.com
I just saw a gem on RubyFlow last week that handles currency conversions using Google as a data source. If that's what you're after, forget what I said and use that.