[CLOSED] Ext.net MVC Globalization problem (culture info)

  1. #1

    [CLOSED] Ext.net MVC Globalization problem (culture info)

    I'm having a problem with Ext.net v3 (and before).

    My Ext.net app use Custom User culture info (it is configured on each user profile). My app is a .net mvc 5

    - So the default web.config culture info is en-US,
    - At any point in the startup of my app I set the culture info of the logged user.
    - Some of the .net culture info are incorrect, for example: in es-EC the number puntuation and date format are incorrect.
    - After set the profile culture I customize some of them (via clone, etc).

    - I found that in the Ext.net resource manager (I can't remember the file and line right now), Ext.net set the CurrentThread culture again internally, so all the customization are lost inside Ext components.

    This is very importan because right now I can't deploy my app for any other language than English.

    Can anyone confirm this behavoir?

    Thanks
    Last edited by Daniil; Feb 17, 2015 at 1:37 PM. Reason: [CLOSED]
  2. #2
    Hello @Igam, and welcome for Ext.NET forums!

    You can define the culture in the ResourceManager itself, thru the Locale parameter.

    For example, you could specify:
    <ext:ResourceManager runat="server" Locale="es-EC" />
    Or, alternatively, as you are going to get this off user profiles (or user session!):

    <ext:ResourceManager runat="server" ID="resMan1" />
    And then in code behind:
    resMan1.Locale = getLocaleFromServer(userId); // for example, returns string "es-EC"
    Well, I hope this is what you need to fix you problem! If not, please let us know.
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Thanks fabricio.murta,

    But that's not my problem. Your give examples in asp.net not in MVC, but setting like that will not work for me and I will tell you why.

    I can setup the locale in different places in my MVC application and Ext.Net will use the configured locale but some culture info in .Net are incorrect (because of number puntuation or date formats) or maybe the devs want to change something.

    So after setting the previous configured User profile culture like this:

    
                Thread.CurrentThread.CurrentCulture = new CultureInfo("es-ES");
                Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES");
    I need to change some culture info like this:

    
    CultureInfo newCulture = System.Globalization.CultureInfo.InvariantCulture.Clone() as CultureInfo;
    
    newCulture.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
    newCulture.DateTimeFormat.DateSeparator = "-";
    newCulture.NumberFormat.CurrencySymbol = "@/.";
    newCulture.NumberFormat.NumberDecimalSeparator = ".";
    newCulture.NumberFormat.NumberGroupSeparator = ",";
    
    newCulture.NumberFormat.CurrencyDecimalSeparator = ".";
    newCulture.NumberFormat.CurrencyGroupSeparator = ",";
    
    newCulture.NumberFormat.PercentDecimalSeparator = ".";
    newCulture.NumberFormat.PercentGroupSeparator = ",";
    
    Thread.CurrentThread.CurrentCulture = newCulture;
    Thread.CurrentThread.CurrentUICulture = newCulture;
    The code change or customize the mvc application, there is no problem outside Ext.net.

    But in Ext.net it will take the current culture info again, and all my customizations are lost inside Ext.net controls.

    I check the source of Ext.net 2 (right now I don't have version 3 sources) and found this:

    ResourceManager.cs line 1133 (sorry I don't have the path), this maybe the reason but not sure how Ext.net handles the locale information.

    
    try
                        {
                            this.currentLocale = new CultureInfo(locale);
                        }
                        catch (Exception)
                        {
                        }
    where locale is a string is set with the locale name like "en-US" (in this case from the browser), the important thing here is that inside Ext.net the Current Thread culture info gets modified again with a standard culture info (without my customizations) instance at some point.


    Let me know if you need more information.
  4. #4
    Okay, I may still have not understood you well, but let's work on it.

    Sorry, I really missed the MVC part! For that you would have a
    @(X.ResourceManager().Locale("es-CE"))
    But I am sure you could make this up yourself. And here is my attempt to get the point you want to show:
    - when loading the locale specified, Ext.NET uses (for example) the "es-CE" specified on the user profile, so all controls will translate correctly.
    - but regardless of how you set regional settings for that culture (currency, decimal separator and so on), Ext.NET reverts it back to some standard, ignoring your regional settings.

    Am I right up to this point?

    Supposing yes, then I believe it will come to ExtJS's localization settings, you will probably need to override them accordingly.

    I am picking these up from the pt_BR localization settings, and they are likely what you want to set appropriately, synced with the user's profile:

        if (Ext.Date)
            Ext.Date.getMonthNumber = function(name) {
                return Ext.Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
    
        if (Ext.util && Ext.util.Format) {
            Ext.apply(Ext.util.Format, {
                thousandSeparator: '.',
                decimalSeparator: ',',
                currencySign: 'R$',
                // Brazilian Real
                dateFormat: 'd/m/Y'
            });
            Ext.util.Format.brMoney = Ext.util.Format.currency;
        }
    Am I following the right path now? I believe you have just to sync these definitions with your local profile's. You can see the full file from any localization by loading an Ext.NET page using that localization setting, and then looking at one of the attached resources (javascripts) with your browser's (or Visual Studio's) debugger.

    Please forgive me if I am still off, maybe there's something I still overlook on your message, if at all we can't make it from this post, then I think the only option would be for you to provide a sample, minimal page code, so I can reproduce the exact issue here and get this sorted out for good.

    More about the simplified error reproducing sample, view forum guidelines on making new topics.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Error in globalization culture
    By ucaneto in forum 2.x Premium Help
    Replies: 3
    Last Post: Jul 16, 2014, 6:00 PM
  2. Replies: 4
    Last Post: Apr 15, 2011, 4:53 PM
  3. TimeField and en-US culture problem
    By Ealirene in forum 1.x Help
    Replies: 1
    Last Post: Mar 21, 2011, 9:00 AM
  4. [CLOSED] Numeric validation culture problem
    By speedstepmem4 in forum 1.x Premium Help
    Replies: 5
    Last Post: May 08, 2009, 11:48 AM
  5. Problem with disable dates, when using culture setting
    By Jurke in forum 1.x Premium Help
    Replies: 5
    Last Post: Feb 26, 2009, 10:25 AM

Posting Permissions