This is a migrated thread and some comments may be shown as answers.

Localization of CurrencyTextBox

4 Answers 459 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Achilles
Top achievements
Rank 1
Achilles asked on 04 Jul 2013, 09:09 AM
Hi,

How do I localize a CurrencyTextBox in razor ? The code
@(Html.Kendo().CurrencyTextBox()
      .Name("Tariff")
      .Spinners(true)
      .Value(305).Culture("de-DE")
always gives me a "$" instead of a "€"

Thanks

Achilles

4 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 08 Jul 2013, 08:21 AM
Hello Raja,

Did you add the reference to the according JavaScript culture file?

http://docs.kendoui.com/api/framework/kendo#methods-culture


Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Achilles
Top achievements
Rank 1
answered on 09 Jul 2013, 06:56 AM
Hello Petur ,

Thanks a lot. This solution works in principle.
I have a question.
In my backend I have a database of users belonging to different countries. There is a field which refers to a tariff in the local currency. When I select a user, I open a new page where I can see/edit the users details.

Since the user can be from any culture, do I have to include all the culture scripts in my Layout.chtml ?

<script src="kendo.culture.en-GB.js"></script>
<script src="kendo.culture.en-IN.js"></script>
<script src="kendo.culture.de-DE.js"></script>
...
...

Or can I load the specific culture dynamically when I load the page?


Secondly, I've noticed something which may be a minor bug. When I set the culture to India,

kendo.culture("en-IN");

I see the currency unit as "Rs" which is the old symbol.
In MVC extension, where I'm trying to migrate from, the symbol is correctly shown as " ₹ "

Thanks and Regards

Achilles
0
Petur Subev
Telerik team
answered on 11 Jul 2013, 08:21 AM
Hello Raja,

To the first question:

You can set your server to load the script dynamically based on the server culture. For example if using ASP.NET MVC as in your case I guess you can use the approach from the documentation:

http://docs.kendoui.com/getting-started/using-kendo-with/aspnet-mvc/globalization#use-the-same-culture-on-the-server-and-client-side

The symbols for the culture and the globalization info is extracted from the .NET. If you want to change some of them you can go and modify the script file - in your case kendo.culture.en-IN.js under the cultures folder of the Scripts.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Achilles
Top achievements
Rank 1
answered on 11 Jul 2013, 10:29 AM
Hello Petur,

That certainly solved the issue. I use CDN . So it was simpler.
All I had to do was

@{
    var culture = ViewBag.Culture;
}
<script src="@Url.Content("http://cdn.kendostatic.com/2013.1.514/js/cultures/kendo.culture." + culture + ".min.js")"></script>


Pity about the India specific currency symbol. Now, I have to copy a specific culture to my scripts folder and load it conditionally, while the rest comes from CDN

 The new symbol ' ₹ ' is updated in .NET. 
I wrote the following code in C#

var cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures);
 
foreach (var cultureInfo in cultures)
{
    var regionInfo = new RegionInfo(cultureInfo.LCID);
 
    if (regionInfo.Name == "IN")
    {
        ViewBag.Currency = cultureInfo.NumberFormat.CurrencySymbol;
    }                
}


and I got it as it is, not "Rs" . If in a later update of Kendo, this specific javascript is updated in CDN, it would be quite nice

Thanks all the same

Regards

Raja
Tags
Editor
Asked by
Achilles
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Achilles
Top achievements
Rank 1
Share this question
or