locked
Resource files RRS feed

  • Question

  • User-1246604461 posted

    Im trying to localize my website.

    In my database I have a table: tblSports
    SportID (PK)
    SportName nchar(30)  (this is the English sport name)


    Now in one page on my site I have a checkboxlist. I want to localize the names of the sport.
    The value of the items in the checckboxlist I think I want to make equal to the PK value in tblSport.

    TestCode.aspx

    <asp:CheckBoxList ID="cblSport" runat="server">

    <asp:ListItem Enabled=true Value="1" Text="<%$ Resources:TestCode, KiteSurfing %>" ></asp:ListItem>

    <asp:ListItem Enabled=true Value="2" Text="<%$ Resources:TestCode, SnowBoarding %>" ></asp:ListItem>

    <asp:ListItem Enabled=true Value="3" Text="<%$ Resources:TestCode, Hiking %>" ></asp:ListItem>

    </asp:CheckBoxList>


    In my App_LocalResources folder I have the following two files:
    TestCode.aspx.resx
    TestCode.aspx.es.resx
    TestCode.aspx.nl.resx

    for example, the .nl.resx file contains:
    Name   Value
    Hiking   Wandelen
    Skating   Schaatsen
    ....


    Now when I load the page I get the following error:
    Parser Error Message: The resource object with key 'KiteSurfing' was not found.

    The obvious question is....why?!? ;)

    btw, im also not sure if my technique of making the values of the listitems equal to the PK's in the table is optimal....is there perhaps a better solution?

    Monday, January 16, 2006 3:29 PM

All replies

  • User1183903743 posted

    Peter,

    You are using global expressions but your data is under a local resource file. For global you have to create a resx manually. For local the invariant should be created automatically by the GLR.

    Also, your choice of keys is fine. Your architecture probably is not. You might want to separate the DAL into an abject and bind that to your list control.

    HTH

     

     

    Monday, January 16, 2006 8:35 PM
  • User-1246604461 posted
    WOW, rookie in tha house here! ;)
    could you explain all that a bit further?

    "The local invariant should be created autonmatically by the GLR." What happens exactely then?

    When I use a DAL and bind it to my listbox control....where does the DAL get the data from? from a database? or can it also be from my .resx? In case of the latter: how do I do that?

    Thanks!
    Tuesday, January 17, 2006 6:27 AM
  • User1183903743 posted

    First of all did you get it fixed by creatinfg a global resx and using that for the expressions?

    There are two issues here. One is related to localization and one to data access.

    "invariant" means default: "Example.aspx.resx":  the no language language and the no place locale. Theoretically its data should never be used. It does serve as the ultimate fallback when a user from a country you do not support and a language you do not support requests your page. However if your site is intended for US audience you should really provide Example.aspx.en-US.resx Also if an occasional Brit or Aussie hits you - Example.aspx.en.resx even if those are identical copies. That way you do not make the system do "assembly probing" which is very costly to perf.

    You should bone up onthe difference b/n Local and Global resources.
    http://beta.asp.net/QUICKSTART/aspnet/doc/localization/localization.aspx

    The utility that abstracts the data from the page to the LOCAL resx is called "Generate Local Resources"(GLR) That is what I was referring to. It is located under the Tools menu. It generates the local expressions/meta tags

    What I meant was that even though you could you should not do the Local invariant yourself but let the GLR do it. Global resx are different. You do the invariant manually yourself.

    Now DAL is an architecture issue not where the data is stored, but how many layers/tiers before it finally shows up on the page. That is debated to death in the blogs etc.

    Test question, how did I know you did not have ANY global resx?

     

     

    Tuesday, January 17, 2006 12:17 PM