Implicit Localisation in ASP.NET 2.0 - How to get it working?

Last post 07-10-2007 9:31 PM by rstrahl. 3 replies.

Sort Posts:

  • Implicit Localisation in ASP.NET 2.0 - How to get it working?

    07-10-2007, 7:24 AM
    • Member
      10 point Member
    • irascian
    • Member since 02-24-2006, 7:50 PM
    • Posts 4

    I can't get implicit localisation of resource strings, as described in various books and articles on globalisation, to work, even though explicit localisation and accessing the resource strings programmatically works fine. Can anybody offer any clues as to what I might be doing wrong?

    I'm generating the resource file using the VS2005 "Tools -> Generate Local Resource" which automatically creates the required local resource file eg MyPage.resx and generates the required implicit localisation in the source. ie:

    <asp:Label ID="lclErrorNumber2" runat="server" meta:resourcekey="lclErrorNumber2" />

    but I never get the required resource string back and in Design View (where the contents should automatically be retrieved if I'm reading the articles correctly) all I see is the name of the control.

    The problem doesn't seem to be with the resource file itself because an explicit declaration like this works fine:

    <asp:Label ID="lclErrorNumber2" runat="server" Text="<%$ Resources: lclErrorNumber2 %>" />

     as does trying to access the resource string programmatically:

    string temp2 = this.GetLocalResourceObject("lclErrorNumber2").ToString();

    Any advice/clues as to possible steps I'm missing would be much appreciated! Have tried variations on the Label control and the new Localize control with no joy and would prefer not to have to resort to Explicit localisation to get round the problem. Thanks.

     

     

  • Re: Implicit Localisation in ASP.NET 2.0 - How to get it working?

    07-10-2007, 7:50 AM
    • All-Star
      62,543 point All-Star
    • TATWORTH
    • Member since 02-04-2003, 8:34 AM
    • England
    • Posts 12,210
    • TrustedFriends-MVPs

    Re "implicit localisation", which controls are you referring to?

    Look at http://www.guysmithferrier.com/ and in particular at Guy Smith's book ISBN 0321341384

    Also his presentation http://www.guysmithferrier.com/downloads/teni18n.pdf

    The controls are not consistent. If you look in his presentation PDF, there are some tips on what to do to fix the problem.

    Don't forget to click "Mark as Answer" on the post that helped you.
    This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped.
  • Re: Implicit Localisation in ASP.NET 2.0 - How to get it working?

    07-10-2007, 8:31 AM
    • Member
      3 point Member
    • durjan
    • Member since 09-14-2006, 11:00 AM
    • London
    • Posts 9

    Try to use "lclErrorNumber2.Text" in resource file instead of lclErrorNumber2.

    If this is a problem.. 

    Durjan Hussain
    M.Sc,SCJP1.4,SCWCD
    www.durjan.co.uk
  • Re: Implicit Localisation in ASP.NET 2.0 - How to get it working?

    07-10-2007, 9:31 PM
    Answer
    • Participant
      1,431 point Participant
    • rstrahl
    • Member since 08-20-2003, 9:08 AM
    • Paia, Hawaii
    • Posts 277
    • ASPInsiders
      TrustedFriends-MVPs

    As somebody else pointed out Implicit resource keys in the resource files themselves have to be of the format ReourcesKey.Property. So your resourcekey should be lcErrorNumber2.Text in the resource file and the meta:resourcekey="lcErrorNumber2". Any properties that that are localizable can be applied.

    The easiest way to make this happen though is to use Generate Local Resources in Visual Studio in the Visual Designer - this will generate the Resource Keys for you in the controls and create them in the resource file so you can somewhat easily see what's actually localizable on the page.

    +++ Rick ---

    Rick Strahl
    West Wind Technologies
    Making waves on the Web
    www.west-wind.com/weblog
Page 1 of 1 (4 items)