Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Currency Conversion / Localization

Posted on 2012-12-28
5
Medium Priority
?
391 Views
Last Modified: 2012-12-28
I'm working on globalization/localization of my MVC3 project. I'm setting the culture info by a user selected language drop down. So it has English/Spanish/Italian/German etc.

This also changes the currency symbol, which is nice, but I'm not sure about the best way to go about actually doing currency conversions in my app. I'd like to have everything stored in my database in dollars and just have the display for any currency amounts in the localized conversion.

After googling around, most of the localization for currencies I saw had to do with the symbol and not with actually doing any conversions...

Is there a good way of doing this? We would most likely have a conversion table that was updated daily, but I'm looking for an easy way to change the display (and only the display) for currencies.
0
Comment
Question by:Josh_Blade
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 13

Assisted Solution

by:themrrobert
themrrobert earned 1000 total points
ID: 38728359
You've pretty much figured it out, you're going to need a table to  store the conversions in, the switch () the language (currency) and select the daily conversion rate for converting USD into the target currency. Multiply the rate X dollar amount and then just display the result.

You can do the same for USD, just make sure USD->USD is always 1, that way you can just use the same function to do all of your conversions, including if its already USD
0
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 38728375
You could try these guys http://www.yourcurrencyconverter.com/

I had a lot of trouble with them and ended up writing my own,  is an example of a client of mine, click the flags:

http://www.amanzitravel.co.uk/product/africa/namibia/volunteer_project/wildlife_conservation_volunteer/namibia_wildlife_sanctuary_av001/index.html

Here is my half-developed site - I haven't finished the automated sign-up, nor are the rates quoted my final rates - I haven't quite decided what to charge. But anyway on the resources tab I explain exactly how to do it so you can roll your own if wished.

http://currency.creative-dreaming.com/
0
 

Author Comment

by:Josh_Blade
ID: 38728466
I guess the biggest thing I'm struggling with is user input. If I have some currency input control, do I need to make sure to unconvert it in my controller when the page gets posted?

I was thinking it would be best to store everything in dollars and display the conversion, but then the users would be inputting information in the converted currency as well and I would have to convert it back to dollars to store in my db.

I'm just trying to find a non tedious way to multiply by conversion rate in the view and then divide by conversion rate in my controller (where applicable) so everything stays consistent.

There might not be an easy way and I just have to suck it up, but above is what I'm looking for.
0
 
LVL 21

Accepted Solution

by:
Dale Burrell earned 1000 total points
ID: 38728487
Well it really depends what your application is. Localisation doesn't always apply to amounts of money. For example if you are selling something, typically you only take payment in a single currency (unless you are a fairly large organisation), and therefore if you do decide to display the amount in another currency its not going to be the exact amount because you aren't the one carrying out the final conversion, therefore you have to be very careful to display loudly and proudly that any amounts displayed in a currency other than the default are indicative only.

So it really depends what your application does, if you fundamentally operate in a single currency then you may be better off forcing everyone to use that. However if the data entered if only for use by the person who enters it, then maybe it should be stored in their native currency - in which case store the currency with the amount.

If you still want to accomplish what you say, which is to store the amounts in dollars, but display the amounts in local currency, then there is no easy way - well rather the conversion is a piece of piss, but obtaining an up-to-date conversion rate is a bit more complex. And keep in mind that while google and yahoo etc do provide conversion API's they are all for non-commercial use.

HTH

So before you decide how to solve the problem, you have to be clear on exactly what you are trying to achieve for the user and whether or not converting money amounts makes logical sense.
0
 

Author Closing Comment

by:Josh_Blade
ID: 38728531
dale_burrell and themrrobert both answered my question pretty thoroughly and gave me some points to think about. Thanks guys.
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question