Normally I would use string.Format()
to get a formatted string.
But I got the requirement that all amounts should be printed as text and not digits.
i.e. something like:
Format(3000, "us"); // => Resulting text: "three thousand dollars"
Are there a .NET library which can handle that (russian is mandatory)?
I've had a look around but I couldn't find a proper version to convert to a English currency, so I combined a few into this solution:
And here is the unit test:
Enjoy this works perfectly :D
Short answer:No.
You have to write your own, I would recommend you to have a look at the following though: converting numbers in to words C# , How can I convert an integer into its verbal representation? and as one of these says, have a look at project Euler problem number 17 and use it for wider google searches.
On top of that you have the issue of currency names, should
'us'
denote the currency or the language or even both? Is the canadian dollar different from the american dollar?For example this is built in:
I would suggest you to start there and see where the path takes you.
There is a mature library for doing with you needd. It's called humanizer.
You can see what it is about here: NuGet Package of the Week: Humanizer makes .NET data types more human
The open source project is on GitHub
As you can see it does what you need and many more things. And it has a lot of localizations.
Some examples:
I haven't tested it out, but maybe this will fix your problem?
Nuget Package
It says it supports Russian language too.
From the package description:
Usage:
For Russian language you can use my library: https://github.com/nick-buhro/NumToWords
It is also available on nuget: https://www.nuget.org/packages/NickBuhro.NumToWords
Example: