Localisation width ASP.NET V2 -Whidbey
[20 mn de lecture - paru le 5/10/2005 12:26:14 PM - Public : Confirmé]
|
   
|
Auteur
2. More explanation
2.1. Possibilities offered by ASP.NET V2
With ASP.NET V2 the localization is simplified.
You have the choice between :
- ResourceManager
- Localisation Implicit
- Localisation Explicit
2.2. To generate the files of Resource RESX
All the pages which you wish to locate, must have their own file of resource RESX. These files of resource can contain controls of the page thus the properties and the values having the attribute of localization.
Whidbey enables you to create quickly the files of resource RESX.
- To create a new page Information.aspx
- To place several controls Web : Label, TextBox, Button, Image et un GridView
- Then in the bar of menu >> Tools >> Generate Local Resource

To look in Solution Explorer.You must see a new File called LocalResources with inside the file of resource : Information.aspx.resx.
The files of resources are defined in the LocalResources. repertory by extension RESX.
A certain convention should be followed :
- /folderRessource/page_name.extension.resx = for to default page, neutral page.
- /folderRessource/page_name.extension.country[-area].resx = for many languages.
Exemple :
- /LocalResources/Default1.aspx.resx
- /LocalResources/Default1.aspx.fr.resx
- /LocalResources/Default1.aspx.fr-car.resx
- /LocalResources/MasterPage1.master.resx
- /LocalResources/MasterPage1.master.fr.resx
or --> /app_globalresources/Default1.aspx.resx width BETA 2 more information : http://msdn.microsoft.com/asp.net/beta2/beta2update.aspx

Open Information.aspx.resx
You should see :

With you to put the values which you wish.
I let to you test..
If you turn over in the Information.aspx page You can note that your controls Web underwent modifications:
<asp:Label ID="Label1" Runat="server" Text="Label" meta:resourcekey="LabelResource1">< FONT>asp:Label> <asp:TextBox ID="TextBox1" Runat="server" meta:resourcekey="TextBoxResource1">< FONT>asp:TextBox> <asp:Button ID="Button1" Runat="server" Text="Button" meta:resourcekey="ButtonResource1" /> <asp:Image ID="Image1" Runat="server" meta:resourcekey="ImageResource1"/> <asp:GridView ID="GridView1" Runat="server" meta:resourcekey="GridViewResource1" >< FONT>asp:GridView>

2.3. Localisation Implicit
The implicit localization must have its own files for each Web page of your Web application. The disadvantage it is that you cannot re-use the file of resource of a page for other page of the application.
<asp:Label id=Label1 meta:resourcekey="resource-key-prefix" runat="server"></asp:Label>
2.4. Localisation Explicit
If you wish to do it you must use the Explicite localization. Attention, the attribute of localization will be only more complex.
The only difference between the implicit localization and clarifies is that the explicit localization can have one or more files of resource, whereas the implicit localization asks for the creation of a file of resource for each page.<asp:Button id=Button1 Text=" <%$ Resources: ClassName, ResoureKey, Default value %> " Runat="server>
In the Page directive you must add the attributes : UICulture =auto et Culture =auto.
|