elimelight wrote:Hi Nicolas,
I couldn't agree more. This has caused me a lot of pain with my customers also. It is a complex set of changes to apply, and I still haven't been able to make it work for UK style date formats - not completely anyway. It works everywhere except where there is also time in the editable field in the back-end. Then, after these changes, the javascript validation simply does not work, and the field is not valid - even if you try and give it US style date again.
I did recently ask for clarification of point 2 in the main suggested changes in page 5 of this thread, but have not had a reply to that, so I am still stuck with looking incompetent to my customers for not being able to switch to UK date formats. The decimal point issue is okay for us in the UK, so it is just this date issue for us.
As you say Nicolas, this should be surely an easy-to-configure setting in such an advanced version of the software as we are with nop commerce now, but the democratic nature of open source is such that a lot of people have to shout about an issue before it is considered important enough for attention. However, surely there are just some functions which should just work, and this is one of them - especially if nop wants to be truly international.
I don't have the deep understanding to even attempt a full solution to this, so I am left with following instructions that I cannot make work fully, and also with the ridiculous situation that when the next version is released, I would have to do it all again, even if I could make it work fully.
Can anyone please, please, please help fix this in the released code?
Thank you, and of course it goes without saying that I am grateful for the fantastic software that nop commerce already is and to all the people that have made this possible by contributing code.
Steve
Hello Steve,
I am not sure about the "fr-CH" format but for UK I have fixed this issue by following
"some" of the steps only. These are detailed on page 3 but here is is again;
Step 1 - at the bottom of _AdminLayout.cshtml page;
change
@(Html.Telerik().ScriptRegistrar()
.jQuery(false)
.jQueryValidation(false)
)
to
@(Html.Telerik().ScriptRegistrar()
.jQuery(false)
.jQueryValidation(false)
.Globalization(true)
)
Step 2 - changes on global.asax file;
As I am using version 3.1, there is only one line of code on my "global.asax" so I had to go to source file (Global.asax.cs) file and make the following change, again towards the bottom of the page/code
change
var culture = new CultureInfo("en-US");
to
var culture = new CultureInfo("en-GB");
Just these two steps above was good enough to display the dates in dd/mm/yyy format on IE and I had no issues with the decimal prices .
However on Google chrome I also experienced an issue with the date picker so I applied the fix on the following page as below;
http://www.codeproject.com/Tips/579279/Fixing-jQuery-non-US-Date-Validation-for-Chrome
Step 3 - add the script to _AdminLayout.cshtml head tag
I have simply added the following code just before my </head> tag;
<script>
// fix date validation for chrome
jQuery.extend(jQuery.validator.methods, {
date: function (value, element) {
var isChrome = window.chrome;
// make correction for chrome
if (isChrome) {
var d = new Date();
return this.optional(element) ||
!/Invalid|NaN/.test(new Date(d.toLocaleDateString(value)));
}
// leave default behavior
else {
return this.optional(element) ||
!/Invalid|NaN/.test(new Date(value));
}
}
});
</script>
And that is it. It all worked for me. I am not sure if I ended up breaking something else but a few tests and page views with changes to prices, dates, kg, mm and similar all proved to working so far.
Have a look at the images below and hope this helps.
http://www.websunami.com/nop3.1-admin-orders.jpghttp://www.websunami.com/nop3.1-admin-product-price.jpg