in

dashCommerce

An ASP.NET Open Source e-Commerce Application

Subsonic disfunctions when language is set to Turkish

Last post 05-30-2008 2:12 AM by yitzchok. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-28-2008 6:54 AM

    Subsonic disfunctions when language is set to Turkish

     Hi,

    When I set language to Turkish in SiteSettings > Globalization, none of the database inserts work. I get the error:

    A critical error has occurred: Object reference not set to an instance of an object.

    I even cannot switch language to English. When I switch it to English or German by updating table dashCommerce_Core_ConfigurationData, everything works fine.

    This is the error log in dashCommerce_Core_Log when I try to add a new child category:

    System.NullReferenceException: Object reference not set to an instance of an object.
       at SubSonic.AbstractRecord`1.ValidateColumnSettings()
       at SubSonic.ActiveRecord`1.Validate()
       at SubSonic.ActiveRecord`1.Save(String userName)
       at MettleSystems.dashCommerce.Web.admin.categoryedit.btnSave_Click(Object sender, EventArgs e) in S:\ADF\AVS\dashCommerce 3.0\Web\admin\categoryedit.aspx.cs:line 224    dashCommerce

    Does anyone come across a situation like this?

    Thanks 

    PS: I guess the problem is about the "Turkish I" problem (See http://www.moserware.com/2008/02/does-your-code-pass-turkey-test.html). 

      

  • 05-29-2008 9:00 AM In reply to

    Re: Subsonic disfunctions when language is set to Turkish

    Hi,

    I found the code part that fails when the language is Turkish.

    The problem can be generated as follows:

    1. "ConfigurationDataId" column in dashCommerce_Core_ConfigurationData table is named as "configurationdataid" in SubSonic table schema which is formed when the culture is English.
    2. In Application_PreRequestHandlerExecute (Global.asax.cs), System.Threading.Thread.CurrentThread.CurrentCulture and System.Threading.Thread.CurrentThread.CurrentUICulture is set to Turkish.
    3. Function below cannot work properly because when "ConfigurationDataId" is lowered during HTTP Request, columnName becomes "configurationdataıd" according to Turkish upper/lowercasing rules, which is different than the one in SubSonic table schema.

                public void SetValue(string columnName, object oVal)
                {
                    columnName = columnName.ToLower(); //EK: Why is this necessary? This method is the only place where ColumnName is set.
                    if(!Contains(columnName))
                    {
                        Add(new TableColumnSetting(columnName, oVal));
                    }
                    else
                    {
                        this[columnName].CurrentValue = oVal;
                    }
                }

    I do not understand the reason why column names are lowered in Subsonic. One reason may be to help -especially Pascal or Visual Basic oriented- programmers that do not write column names int the same way they are coded in database.

    For a shortcut patch, I replaced each string.ToLower() function to string.ToLower(System.Globalization.CultureInfo.InvariantCulture) in TableSchema.cs in SubSonic project where the above code is now:

    columnName = columnName.ToLower(System.Globalization.CultureInfo.InvariantCulture); //EK: Why is this necessary? This method is the only place where ColumnName is set.

    The patch seems to work but I am not sure about the side effects.

    During the analysis of this situation, I come to a conclusion that SubSonic -therefore dashCommerce- is not 100% Turkish compliant as most of the string related codes in SubSonic (such as Regular expresions for ALPHA, LOWERCASE constants,string validator functions) does not take local alphabets and .NET's CurrentCulture into account. For example in Constants.cs (SubSonic) ALPHA is coded as

    public const string ALPHA = "[^a-zA-Z]"; 

    However Turkish version should be 

    public const string ALPHA = "[^a-zA-ZçğıöşüÇĞİÖŞÜ]";

    I think the same problems may arise for other languages such as German.

  • 05-29-2008 9:29 AM In reply to

    Re: Subsonic disfunctions when language is set to Turkish

    Hi Kommers,

    Good work on smoking that out. This is probably best reported in the SubSonic forums as we don't have any direct impact on that project. Good to know though.

    --
    Support dashCommerce - Buy Our Stuff!!


    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us! Documentation? Help us write some!
    Filed under:
  • 05-30-2008 2:12 AM In reply to

    Re: Subsonic disfunctions when language is set to Turkish

    I posted this bug to SubSonic Issue tracker
    http://www.codeplex.com/subsonic/WorkItem/View.aspx?WorkItemId=16859

    Thanks Kommers

    Find a bug? Create a Work Item for a fast response.. Want to help? Create a patch for us!
Page 1 of 1 (4 items)