![]() |
|
|
|||||||
![]() |
ASP Net - Trying localization with Sams Tips&Tricks |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Hi,
I have a very good book on asp.net Sams ASP.NET Tips, Tutorials and Code ISBN 0-672-32143-2 and is trying to teach myself from examples from this book Chapter 16. Anyway I come quite close when trying to run one example but then I get this message I don't understand: "This .resources file shouldn't be used with this reader. Your resource reader type: System.Resources.ResourceReader, mscorlib, Version=1.0.2411.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" What does it mean? Seems my english isn't good enough. TIA Kenneth P =?Utf-8?B?S2VubmV0aCBQ?= |
|
|
|
|
#2 |
|
Posts: n/a
|
Hi,
can you post us the code ? regards Joyjit "Kenneth P" <> wrote in message news:626575AC-8773-4026-8A90-... > Hi, > > I have a very good book on asp.net Sams ASP.NET Tips, Tutorials and Code > ISBN 0-672-32143-2 and is trying to teach myself from examples from this book > Chapter 16. > > Anyway I come quite close when trying to run one example but then I get this > message I don't understand: > > "This .resources file shouldn't be used with this reader. Your resource > reader type: System.Resources.ResourceReader, mscorlib, Version=1.0.2411.0, > Culture=neutral, PublicKeyToken=b77a5c561934e089" > > What does it mean? > > Seems my english isn't good enough. > > TIA > > Kenneth P |
|
|
|
#3 |
|
Posts: n/a
|
Hmmm...
Where should I post it, because it contains five very small (1kb) compiled resource files as well as the code? Kenneth P "Joyjit Mukherjee" wrote: > Hi, > > can you post us the code ? > > regards > Joyjit > > "Kenneth P" <> wrote in message > news:626575AC-8773-4026-8A90-... > > Hi, > > > > I have a very good book on asp.net Sams ASP.NET Tips, Tutorials and Code > > ISBN 0-672-32143-2 and is trying to teach myself from examples from this > book > > Chapter 16. > > > > Anyway I come quite close when trying to run one example but then I get > this > > message I don't understand: > > > > "This .resources file shouldn't be used with this reader. Your resource > > reader type: System.Resources.ResourceReader, mscorlib, > Version=1.0.2411.0, > > Culture=neutral, PublicKeyToken=b77a5c561934e089" > > > > What does it mean? > > > > Seems my english isn't good enough. > > > > TIA > > > > Kenneth P > > > |
|
|
|
#4 |
|
Posts: n/a
|
Sure, why not,
Here's the code for the .aspx, named 16.3.2.aspx <%@ Page Inherits="myCodeBehind_1633" Src="16.3.3.vb" ResponseEncoding="utf-8" %> <html> <head> <title>Using Resource Files in ASP.NET</title> </head> <body style="FONT: x-small Verdana, Arial, sans-serif"> <form method="post" runat="server"> <b>The Current Culture is:</b> <asp:Label id="CultureType" runat="server"></asp:Label> <hr /> <p> <b> <asp:Label id="Welcome" runat="server"></asp:Label> </b> </p> <p> <b> <asp:Label id="Choose" runat="server"></asp:Label> </b> <asp AutoPostBack="True"> <asp:ListItem Value="en-US" Text="English" /> <asp:ListItem Value="en-NZ" Text="English (New Zealand)" /> <asp:ListItem Value="fr-FR" Text="French" /> <asp:ListItem Value="de-DE" Text="German" /> <asp:ListItem Value="he-IL" Text="Hebrew" /> <asp:ListItem Value="ja-JP" Text="Japanese" /> <asp:ListItem Value="es-MX" Text="Spanish (Mexican)" /> <asp:ListItem Value="uk-UA" Text="Ukrainian (Ukraine)" /> </asp </p> <asp AutoGenerateColumns="False" HeaderStyle-ForeColor="White" HeaderStyle-BackColor="Black" Font-Size="8pt" Font-Name="Verdana" ShowFooter="false" BorderColor="black" Width="740"> <Columns> <asp:BoundColumn DataField="FirstName" /> <asp:BoundColumn DataField="LastName" /> <asp:BoundColumn DataField="BirthDate" DataFormatString="{0 <asp:BoundColumn DataField="HireDate" DataFormatString="{0 </Columns> </asp </form> </body> </html> and here's the code behind file 16.3.3.vb Imports System Imports System.Data Imports System.Data.SqlClient Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.HtmlControls Imports System.Globalization Imports System.Threading Imports System.Resources Imports System.IO Public Class myCodeBehind_1633 : Inherits Page Public myDataGrid As DataGrid Public EncodType As DropDownList Public CultureType As Label Public Choose As Label Public Welcome As Label Public rm As ResourceManager = ResourceManager.CreateFileBasedResourceManager("my ResourceFile", Server.MapPath("/resources") & Path.DirectorySeparatorChar, Nothing) Public Sub Page_Load(Sender As Object, E As EventArgs) Dim culture As CultureInfo Dim myDataAdapter As SqlDataAdapter Dim myDataSet As New DataSet If Not Page.IsPostBack Then culture = CultureInfo.CurrentCulture Else culture = New CultureInfo(EncodType.SelectedItem.Value) Thread.CurrentThread.CurrentCulture = culture End If CultureType.Text = culture.EnglishName Welcome.Text = rm.GetString("Greeting", culture) Choose.Text = rm.GetString("EncMessage", culture) myDataGrid.Columns(0).HeaderText = rm.GetString("FirstName", culture) myDataGrid.Columns(1).HeaderText = rm.GetString("LastName", culture) myDataGrid.Columns(2).HeaderText = rm.GetString("BirthDate", culture) myDataGrid.Columns(3).HeaderText = rm.GetString("HireDate", culture) myDataAdapter = New SqlDataAdapter("Select LastName, FirstName, BirthDate, HireDate From Employees", _ "server=localhost;database=Northwind;uid=sa;pwd=oh lywohly;") myDataAdapter.Fill(myDataSet, "Employees") myDataGrid.DataSource = myDataSet.Tables("Employees").DefaultView myDataGrid.DataBind() End Sub End Class and here's the code for the five resources files. you have to compile them first before using them using resgen C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.de-DE.txt C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.de-DE.resources resgen C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.fr-FR.txt C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.fr-FR.resources resgen C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.en-NZ.txt C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.en-NZ.resources resgen C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.es-MX.txt C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.es-MX.resources resgen C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.txt C:\Inetpub\wwwroot\Sams\TipsTricks\C16\resources\m yResourceFile.resources first 'myResourceFile.de-DE.txt' [strings] Greeting = Willkommen! FirstName = Vorname LastName = Familienname BirthDate = Geburtsdatum HireDate = Miete-Datum EncMessage = Wählen Sie Ihre Verschlüsselung: and then no two with the name 'myResourceFile.en-NZ.txt' [strings] Greeting = Good Day! and number three 'myResourceFile.es-MX.txt' [strings] Greeting = Bienvenido! FirstName = Nombre de pila LastName = Apellido BirthDate = Fecha de Nacimiento HireDate = Fecha de Alquiler EncMessage = Escoja su codificación: number four: 'myResourceFile.fr-FR.txt' [strings] Greeting = Accueil! FirstName = Prénom LastName = Nom de famille BirthDate = Date de Naissance HireDate = Date de Location EncMessage = Choisissez votre codage: and at last number 5: 'myResourceFile.txt' [strings] ; ; lines beginning with semi-colons are treated as comments ; ; Specify a locale-specific welcome message Greeting = Welcome! ; ; Create locale-specific header text for our DataGrid FirstName = First Name LastName = Last Name BirthDate = Birth Date HireDate = Hire Date ; ; Create locale-specific text for our Label EncMessage = Choose your encoding: The .resources files should be saved to a /resources directory below the root directory. Kenneth P. "Joyjit Mukherjee" wrote: > Hi, > > can you post us the code ? > > regards > Joyjit > > "Kenneth P" <> wrote in message > news:626575AC-8773-4026-8A90-... > > Hi, > > > > I have a very good book on asp.net Sams ASP.NET Tips, Tutorials and Code > > ISBN 0-672-32143-2 and is trying to teach myself from examples from this > book > > Chapter 16. > > > > Anyway I come quite close when trying to run one example but then I get > this > > message I don't understand: > > > > "This .resources file shouldn't be used with this reader. Your resource > > reader type: System.Resources.ResourceReader, mscorlib, > Version=1.0.2411.0, > > Culture=neutral, PublicKeyToken=b77a5c561934e089" > > > > What does it mean? > > > > Seems my english isn't good enough. > > > > TIA > > > > Kenneth P > > > |
|