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

  • Question

  • User-941998522 posted

    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.

     

     

    Tuesday, July 10, 2007 7:24 AM

Answers

  • User1622957740 posted

    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 ---

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 10, 2007 9:31 PM

All replies

  • User-319574463 posted

    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.

    Tuesday, July 10, 2007 7:50 AM
  • User797518472 posted

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

    If this is a problem.. 

    Tuesday, July 10, 2007 8:31 AM
  • User1622957740 posted

    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 ---

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, July 10, 2007 9:31 PM