Fai Wong
2013-Sep-24 14:55 UTC
What is the best way to convert a currency string ''USD'' to locale :en-US?
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: <%= number_to_currency(1234567890.506, :locale => :en-GB) %> -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6a048984-c6e2-4d36-a947-96f3327a1f74%40googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Walter Lee Davis
2013-Sep-24 15:58 UTC
Re: What is the best way to convert a currency string ''USD'' to locale :en-US?
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. Walter On Sep 24, 2013, at 10:55 AM, Fai Wong wrote:> 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: > > <%= number_to_currency(1234567890.506, :locale => :en-GB) %> > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6a048984-c6e2-4d36-a947-96f3327a1f74%40googlegroups.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/328067F8-25F2-48CE-930C-CCF68A886459%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.
Peter Hickman
2013-Sep-24 19:41 UTC
Re: What is the best way to convert a currency string ''USD'' to locale :en-US?
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. On 24 September 2013 16:58, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote:> 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. > > Walter > > On Sep 24, 2013, at 10:55 AM, Fai Wong wrote: > > > 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: > > > > <%= number_to_currency(1234567890.506, :locale => :en-GB) %> > > > > -- > > You received this message because you are subscribed to the Google > Groups "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send > an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/6a048984-c6e2-4d36-a947-96f3327a1f74%40googlegroups.com > . > > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/328067F8-25F2-48CE-930C-CCF68A886459%40wdstudio.com > . > For more options, visit https://groups.google.com/groups/opt_out. >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALxYQy4v1s_n3N1jDjo4tmWQrpaUM3tE95Jj%3Dj0QqP48nKMh9g%40mail.gmail.com. For more options, visit https://groups.google.com/groups/opt_out.
Walter Lee Davis
2013-Sep-24 19:45 UTC
Re: What is the best way to convert a currency string ''USD'' to locale :en-US?
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. Walter On Sep 24, 2013, at 3:41 PM, Peter Hickman wrote:> 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. > > > > On 24 September 2013 16:58, Walter Lee Davis <waltd-HQgmohHLjDZWk0Htik3J/w@public.gmane.org> wrote: > 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. > > Walter > > On Sep 24, 2013, at 10:55 AM, Fai Wong wrote: > > > 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: > > > > <%= number_to_currency(1234567890.506, :locale => :en-GB) %> > > > > -- > > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/6a048984-c6e2-4d36-a947-96f3327a1f74%40googlegroups.com. > > For more options, visit https://groups.google.com/groups/opt_out. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/328067F8-25F2-48CE-930C-CCF68A886459%40wdstudio.com. > For more options, visit https://groups.google.com/groups/opt_out. > > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CALxYQy4v1s_n3N1jDjo4tmWQrpaUM3tE95Jj%3Dj0QqP48nKMh9g%40mail.gmail.com. > For more options, visit https://groups.google.com/groups/opt_out.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/61631FDC-14C9-4E18-8D44-AB9779C1F448%40wdstudio.com. For more options, visit https://groups.google.com/groups/opt_out.