CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Forum has moved

New location: CSLA .NET forum


CSLA .NET Resources:
  • CSLA .NET forum
  • CSLA .NET home page
  • a localization problem !

    rated by 0 users
    This post has 6 Replies | 3 Followers

    Not Ranked
    Posts 5
    rexhxiao Crying [:'(] Posted: Sun, Oct 7 2007 2:07 PM

    i come from taiwan

    use csla.net 3.0.2.0

    i have code like this:

        ValidationRules.AddRule(
                  Csla.Validation.CommonRules.StringRequired,
                  new Csla.Validation.RuleArgs("CaseType", "案件類別"));

    it is work show message => "案件類別 required"

    follow Resources.zh-TW.resx

    i hope it is show => "案件類別 不可空白"

    my OS is chinese trandtional version

    so..how to do it?

    i trace csla source code find it

            internal static string StringRequiredRule
            {
                get
                {
                    return ResourceManager.GetString("StringRequiredRule", resourceCulture);
                }
            }

    try replace

        return ResourceManager.GetString("StringRequiredRule", resourceCulture);
    to

        return ResourceManager.GetString("StringRequiredRule" + resourceCulture.DisplayName, resourceCulture);

    the
     private static global::System.Globalization.CultureInfo resourceCulture;

    got a null exception..

    why?,i don't know ?

    My poor English, hoping that someone will see to understand, about my question

    Top 10 Contributor
    Posts 9,475

    My guess is that you need to have a resource.zh.resx file.

    In other words, your OS is not set to use Tiawanese, but to use Traditional Chinese. So .NET looks for the traditional Chinese resource file, and perhaps there isn't one?

    I don't know what the code is for traditional Chinese. Is it zh or zh-CHS?

    You need to have a resource file with an exact match on the culture code OR a resource file that is more general (like resource.zh.resx).

    So maybe you can try renaming .zh-TW to just .zh and see if that helps.

    The final default is English, because that is what is in resource.resx.

    Rocky

    Not Ranked
    Posts 5
    Really thank you to respond to my questions
     
    First, resource.zh - TW.resx is from 「cslacs - 3.0.2 - 070928 」
    I think this is not a problem
    Because if I replace
    ----------------------------------------------
        Return ResourceManager.GetString ( "StringRequiredRule" resourceCulture);
    ----------------------------------------------
    Changed
    ----------------------------------------------
        Return ResourceManager.GetString ( "StringRequiredRule" System.Globalization.CultureInfo.CurrentCulture);
    ----------------------------------------------
    That is right, that is, I want
    ==> "案件類別 不可空白"  (in english,mean is 「CaseType required」)
    Therefore, resource.zh - TW.resx is no problem

    My question is, why is null resourceCulture
     
    ps.In Taiwan,xp OS version is Traditional Chinese,the CultureInfo name is 「zh-TW」.
     
    Once again thanks
    Not Ranked
    Posts 9
    foxhard replied on Tue, Nov 30 2010 3:12 PM

    Hi,

    I have the same problem...

    But , is changing the CSLA source code the unique way to apply localization in the validation rule messages?

    I guess must there be another solution...

    I have added csla.dll (Not the source code of CSLA only the assembly) as reference in my project. And I have in my project WinApp  \Properties\Resources.no.resx. And inside this file I have 

    Name                                      Value

    StringRequiredRule             er påkrevd

     

    But when I ran my application the text continue in english: "Fieldxxx required.

    What happens? the text "requires" should be "er påkrevd"

     

    I hope you can help me.

    Cristhiam

     

     

     

     

     

    Top 10 Contributor
    Posts 9,475

    The rules implemented in CommonRules rely on resource files for localization. If you don't like the text you get as a result there are two options.

    First, if the localization for your language is wrong, or doesn't exist, please email me an updated resx file for your language. Obviously "wrong" can't be specific to your application, but must be "wrong for your entire language".

    Second, if your application requires some specific text other than what's in the CommonRules implementation (in other words, the CommonRules language is "correct" but just doesn't work for you), then you should create your own rule implementation.

    At no point should you feel the need to change the CommonRules implementation itself. The whole idea behind the CSLA rules subsystem is that you can create your own rules if you need them.

    Rocky

    Top 10 Contributor
    Posts 2,279
    JonnyBee replied on Wed, Dec 1 2010 12:22 AM

    First , please check that the resource file is complete with all keys translated from the main resource file.

    ResEx is an excellent tool for this: http://resex.codeplex.com/

    If the resource file is wrong or needs updating please submit to Rocky as described above.  

    Which resource file is used when retrieving text is depending on the CultureInfo on current thread. For a Windows forms application you could force en-US culture using these lines in startup:

    using System.Globalization;
    using System.Threading;
    ...
    Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
    Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-US");

    Jonny Bekkum, Norway CslaContrib Coordinator

    Not Ranked
    Posts 13
    ksavoie replied on Fri, Apr 8 2011 8:45 AM

    Hi

    I'm looking into using the Localization in my custom Validation rules.  I left the following question under a different discusion without any answer, I'm hoping you can help me.

    I've created my custom Validation rules ok and they work fine.  I using windows form (vb.net 2005 with CSLA 2.0), and my users have the option to change the language of the application.  With this I need to be able to show the error message in the different language.  I can change my CultureInfo no problem, my problem is...

    I've used the following code to access the resources files:

     Dim mRS As New ResourceManager("frmMain", System.Reflection.Assembly.Load("frmMain"))

    And in my custom rule this is the code I'm using:

    e.Description = mRS.GetString("Invoice_Name")

    When I do this, I get a Fetch failed (DataPortal.Fetch failed, Message: "Exception has been thrown by the target of an invocation.").  I've tried a few things, and when I thought I had the right code, I was getting a Serialization exception on the save.

    So do you think it would be possible to get an example on localization inside the object itself to help me out?

    Thanks

    K

    Page 1 of 1 (7 items) | RSS

    Copyright (c) 2006-2014 Marimer LLC. All rights reserved.
    Email admin@lhotka.net for support.
    Powered by Community Server (Non-Commercial Edition), by Telligent Systems