When updating prices in NopCommerce Product edit, the zeroes behind the dot is added to the number.
e.g. 440.0000 becomes 4400000
The prices is stored in a decimal type. The language used on the client machine is Danish, which normally uses ',' as decimal separator. In the Edit webpage dot '.' is used as decimal separator and it will not accept ','. By googling around I have seen that other Danes has had the same problem.
This question and answer could identify the problem and a maybe offer a solution. Can anyone tell me how to implement it in NopCommerce?
It is not an option to make any change in the NopCommerce source code, despite it's "open source", because I am trying to fix a legacy system.
The problem occurs in both Chrome and Firefox.
Depending on the version of nopCommerce you use have a look at
Global.asax.cs - SetWorkingCulture()
if (webHelper.GetThisPageUrl(false).StartsWith(string.Format("{0}admin", webHelper.GetStoreLocation()),
StringComparison.InvariantCultureIgnoreCase))
{
//admin area
//always set culture to 'en-US'
//we set culture of admin area to 'en-US' because current implementation of Telerik grid
//doesn't work well in other cultures
//e.g., editing decimal value in russian culture
CommonHelper.SetTelerikCulture();
}
ComonHelper.cs - SetTelerikCulture()
public static void SetTelerikCulture()
{
//little hack here
//always set culture to 'en-US' (Kendo UI has a bug related to editing decimal values in other cultures). Like currently it's done for admin area in Global.asax.cs
var culture = new CultureInfo("en-US");
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
The above code blocks represent nopCommerce 3.90.
It is not an option to make any change in the NopCommerce source code, despite it's "open source", because I am trying to fix a legacy system.
Since you do not want to change the nopCommerce source code, you have no choice but to use nop Admin using en-US culture.
Edit
One thing you could try is adding one of the culture scripts provided by telerik. See ~/Scripts/kendo/2014.1.318/cultures/...
Although this requires a minor change on a view (source code)
This answer just to close the question. Thanks to Raphael for his answer.
The only way to solve the problem is to set working culture and make a recompile, which as written in the question is not an option. Because I don't know if there are any custom changes in the legacy compilation.
Related
I am developing one MVC4 application, in that there is option for language seletion in my application & based on that selected lanaguage, all label & messages are displayed.In this application i have put one required field validation of MVC, and it will display validation message in english only.I have created two different xml file for Localization in my application folder i.e Resource.resx for english lanaguage & Resource.de-DE.resx for German langauge. I have used the following code in my Model class :
[Required(ErrorMessageResourceType = (typeof(MyFolder.MyResource.Resource)), ErrorMessageResourceName= "FromDateRequiredMessage")]
[Display(Name = "FromDate", ResourceType = typeof(MyFolder.MyResource.Resource))]
public DateTime FromDate { get; set; }
So here i have Resource.resx xml file and in that i have Key is 'FromDateRequiredMessage' which is same key as in Resource.de-DE.resx german file but different value.Also i have make the follwing changes in my in web.config file for globalization :
<globalization enableClientBasedCulture="true" culture="auto" uiCulture="auto"/>
So, i want that when i select the german language from my application, then it should show me validation error in german language.But here it will show me validation message in english only.
So, now what can i do for this? Please hel me.
Please use method Application_PreRequestHandlerExecute() in your application's Global.asax file. This method will execute before any page request or its validation.
Also set the current culture value in this method.
Simple answer > nothing is wrong!
when you put culture=auto in web.config it works this way, your application will look at the header of the incoming request and look for accept languages and the order of them, so in one request in it you have something like En - Fa ... the application will select the first one and set culture an ui culture to that, so go to your browser language settings and change the order of the languages to test your application.
In order to be able to do this you will need to set the culture. So will provide the user with selection in dropdown etc which they explicity select German,English etc, this will change yoursite to be yoursite/En or yoursight/Gr etc. This article explains in well and gives sample code. http://www.codeproject.com/Articles/207602/Creating-a-Bilingual-ASP-NET-MVC3-Application-Part the part "Adding UI support to switch languages" has what you need i believe.
I am developing a Japanese mobile site using Datebox calendar. I managed to override most of the date format and labels, but I'm not sure how to modify the title which shows the Month and Year. Instead of showing 6月2013, I want it to show 2013年6月. The two characters basically represent year and month.
I'm using Datebox version 1, and I have overriden the dateFormat and headerFormat as listed below. What am I missing here?
http://dev.jtsage.com/jQM-DateBox1/demos/api/matrix.html#matrix&ui-page=0-0
It's been a long time since I played with v1. But...
Think about upgrading the v2. Language files stay the same, but v2 is way, way more stable.
You have a couple options for headerFormat -
a. you can either mess with it in the language file (which I assume you are loading, judging by the fact that english is the default).
b. Override options..headerFormat.
c. It looks like just setting options.headerFormat is supposed to override it too... ymmv. Like I said, it's been a while.
The bad news: It is possible that the calendar mode of v1 does not in fact use headerFormat - if that is the case, look for this line, around about 1421, which looks suspiciously hard-coded to me. Which means you'll need to edit the sources directly. Sorry about that.
self.controlsInput.empty().html(o.lang[o.useLang].monthsOfYear[self.theDate.getMonth()] + " " + self.theDate.getFullYear());
Finally, if you do decide to upgrade to v2, it looks like it is also hardcoded - line 160. I'll work on making this an option instead. Edit: the option you are looking for in v2 is overrideCalHeaderFormat / calHeaderFormat.
I've a small problem with my Asp.Net MVC.
For now I've developed a website in english, everything is working fine, all my texts are already in localization, and I've already a session based system. When I go to another language(in my case french), it changes the Thread.CurrentThread.CurrentUICulture and Thread.CurrentThread.CurrentCulture to a culture info created from "fr".
All my traductions is working, but I've a problem in one form.
In France, the decimal part is separated from the integer part with ",". The server validation works fine with it and translate "234,512"(and know transforms "234.512" too)into a double.
But the client validation doesn't accept this, it says:
"Le champ XYZ doit être un nombre."
So it has the correct local(because the message is translated in french), but it seems to want the number edited in "235,55".
At start I thought it wasn't a big deal, users can enter number with the "234.512" format, but the problem is for the edition of data, since the thread is in French, it fill the model with "234,512", and not "234.512", and because of that customer must change the separator on every change(event if they don't make change on this field) otherwise they get a client validation error(no call are being made when I press on the submit button, I checked several times).
So what should I do to have the client validation script for double working in the current locale?
Thank you very much!
It seems to be a problem with the jquery.validate.js (or jquery.validate.unobtrusive.js), which only accepts dots as separators.
Take a look on the following post for a solution:
http://www.mfranc.com/2011/07/05/jquery-valdiator-modyfing-decimal-separator/
or
http://www.campusmvp.net/asp-net-mvc-3-and-the-coma-in-decimals/
It is known problem. Javascript validators inside jquery doesn't allow anything except point.
The simplest way is to change jquery.validate.min.js (or so) or override custom validator inside your cshtml. Inside jquery it will be:
// http://docs.jquery.com/Plugins/Validation/Methods/number
number: function(value, element) {
//return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/.test(value); <-- original
return this.optional(element) || /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:[\.,]\d+)?$/.test(value);
},
We have code in our system to format numbers and currency according to the regional settings selected by the user. One of our users has selected en-ZA and noticed that the digit grouping and decimal separators have changed with our migration to .NET 4.0.
I wrote a snippet of code to illustrate this change:
using System;
namespace regional
{
class Program
{
static void Main(string[] args)
{
var ci = new System.Globalization.CultureInfo("en-ZA");
var output = 1234567.00m.ToString("c", ci);
Console.WriteLine(output);
}
}
}
Under .NET 3.5, we get output that looks like this:
R 1,234,567.00
Under .NET 4.0, we get output that looks like this:
R 1 234 567,00
What accounts for the change in decimal separator and digit grouping between .NET 3.5 and .NET 4.0?
According to Wikipedia, "When South Africa adopted the metric system, it adopted the comma as its decimal separator." This implies that this setting changed at some point, but I still don't have insight as to why the behavior is different between the different framework versions.
The .net team review stuff like this based on consumer feedback - presumably enough people petitioned them to say the existing settings were incorrect so they changed them.
http://msdn.microsoft.com/en-us/library/dd997383.aspx#updated_globalization_property_values
basically says "we update globalization settings between versions", and
http://msdn.microsoft.com/en-us/library/dd997383.aspx#getting_current_globalization_information
says that from Windows 7 onwards they in fact load globalization data from the OS (so potentially en-za will appear differently under different operating systems, at different points in time). Also
Because of the ever-changing world, globalization information is subject to change at any time; developers should not expect the values of globalization properties to persist between releases, or even for the same release of the .NET Framework
i need to localize a Reporting Services-report (.rdlc) and i would like to do it using a ressource-file (.resx).
I found pages like this and that and they use custom code to achieve their target.
But pages like Setting the Report Language Parameter in a URL give me the impression that localization in reports is possible without custom code.
So, it is possible to localize a Reporting Services-report without custom code ?
If so, is there a tutorial that explains how it's done?
What in the report do you want to localize?
values from the database? Those should be retrieved from the database in the appropriate language already
fixed labels and textboxes on the report? I have not yet seen any compelling way to doing this - you can either have
one report "skeleton" / template per language (and pick the one you need)
if the number of elements is manageable, define report parameters which you can set from the calling code, to set the labels and texts
use some custom .NET extension for handling localization
It's not really an awfully pretty picture, indeed - I'd be most interested in better solutions myself! (I typically need to support 3-4 languages for any report - and I'm using only server-based .RDL files, no .RDLC, so any localization that depends on client-side resource files is not usable in my case)
I would add one method when it comes to labels and textboxes:
Create a placeholder element within the textbox and use Expression field to
use a Switch clause , switching on the Language parameter.
It's not superpretty, but also works pretty well for 3-4 languages
I am passing parameters to the report for labels etc, and after adding the parameters to the report (using the menu option Report -> Parameters in VS2008) you can then use the values of these parameters to localise the labels. This is workiiing well enough, although it would be nicer to be abkle to refer to resource keys immediately from your form labels etc.