Nopcommerce: Admin area (KendoUI) localization and globalization

Created on 14 Jan 2016  路  5Comments  路  Source: nopSolutions/nopCommerce

UPDATE: postponed after https://github.com/nopSolutions/nopCommerce/issues/75

It causes some issues. So let's make it configurable (allow a store owner to disable it).Also note that we're going to move away from KendoUI. So should we do it?

Please see http://docs.telerik.com/kendo-ui/getting-started/framework/globalization/overview and http://docs.telerik.com/kendo-ui/getting-started/using-kendo-with/aspnet-mvc/globalization

also see http://www.nopcommerce.com/boards/t/19235/latest-telerik-version-incorrectly-shows-decimals-in-different-locales.aspx and http://www.nopcommerce.com/boards/t/2653/how-to-change-date-format-for-admin-interface.aspx and http://www.nopcommerce.com/boards/t/24688/languagedecimal-formatting-bug.aspx

How it can be done:

  1. Set server-side culture in Global.asax.cs. Always invoke the following code (not just "not in admin area"):
    CommonHelper.SetTelerikCulture();
  2. Update CommonHelper.
    Add:
public static bool ForceEnUsCulture()
    {
        var forceEnUsCulture = !String.IsNullOrEmpty(ConfigurationManager.AppSettings["ForceEnUsCulture"]) &&
              Convert.ToBoolean(ConfigurationManager.AppSettings["ForceEnUsCulture"]);

        return forceEnUsCulture;
    }

and replace "SetTelerikCulture" with

/// <summary>
    /// Set Telerik (Kendo UI) culture
    /// </summary>
    public static void SetTelerikCulture()
    {
        if (ForceEnUsCulture())
        {
            //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;
        }
    }
}
  1. Update /Nop.Web/Administration/Views/Shared/_AdminLayout.cshtml

Add:

var kendoVersion = "2014.1.318"; 
var forceEnUsCulture = CommonHelper.ForceEnUsCulture(); 
var currentKendoCulture = EngineContext.Current.Resolve<IWorkContext>().WorkingLanguage.LanguageCulture;

then add (before registration of kendo.web.min.js:

//javascript resources
if (!forceEnUsCulture)
{
    Html.AppendScriptParts(string.Format("~/Scripts/kendo/{0}/cultures/kendo.culture.{1}.min.js", kendoVersion, currentKendoCulture));
}

then add (in HTML)

@if (!forceEnUsCulture)
{
            <script type="text/javascript">
                //set kendo UI culture
                kendo.culture("@(currentKendoCulture)");
            </script>
            }
  1. Update import/export so it works in en-US only

But it still does not work properly when other cultures are used (e.g. ru-RU):

  1. Grids always send edited values in en-US culture (AJAX)
  2. Getting "The field XXX must be a number" validation errors on standard pages

[AM] Also see comments below

functionality / feature

Most helpful comment

I think this a very important feature/fix that improves admin usability
nop is also using a very old version of kendoui? had issues before when using newer kendoui features in custom plugins...

tx! :)

All 5 comments

I think this a very important feature/fix that improves admin usability
nop is also using a very old version of kendoui? had issues before when using newer kendoui features in custom plugins...

tx! :)

How far away is this? We have a few issues with our invoices being in US format for the date which has confused some of our customers.

@AndreiMaz

Will Nop still using Kendo UI?
As per my knowledge, Kendo UI is replaced by DataTable.

Closed #30

Must be solved in this task - #5016

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AndreiMaz picture AndreiMaz  路  4Comments

AndreiMaz picture AndreiMaz  路  3Comments

mmccann-umph picture mmccann-umph  路  3Comments

rustybox picture rustybox  路  7Comments

AndreiMaz picture AndreiMaz  路  3Comments