[Mono-bugs] [Bug 585933] New: DropDownList items and GridView columns don't translate.
bugzilla_noreply at novell.com
bugzilla_noreply at novell.com
Fri Mar 5 14:48:54 EST 2010
http://bugzilla.novell.com/show_bug.cgi?id=585933
http://bugzilla.novell.com/show_bug.cgi?id=585933#c0
Summary: DropDownList items and GridView columns don't
translate.
Classification: Mono
Product: Mono: Class Libraries
Version: 2.6.x
Platform: All
OS/Version: All
Status: NEW
Severity: Normal
Priority: P5 - None
Component: Sys.Web
AssignedTo: mhabersack at novell.com
ReportedBy: kuritsu at gmail.com
QAContact: mono-bugs at lists.ximian.com
Found By: ---
Blocker: ---
Created an attachment (id=346878)
--> (http://bugzilla.novell.com/attachment.cgi?id=346878)
A MonoDevelop project that shows the bug.
User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; es-MX; rv:1.9.1.5)
Gecko/20091109 Ubuntu/9.10 (karmic) Firefox/3.5.5
I have an ASP.NET web page with a DropDownList with items with the
meta:resourcekey attribute. I also have a GridView with columns defined by
BoundFields that also have the meta:resourcekey attribute. I also have .resx
files with the correct names and strings for several cultures/languages, inside
the App_LocalResources directory. I also set culture="auto" as attribute of the
@Page tag inside the aspx file. In the code behind, I override the
InitializeCulture and set the thread and page culture to the one set in a
session variable. I also put several buttons to change the page's
language/culture and a label with meta:resourcekey to show that the culture
changes correctly. The problem is that nor ListItems from the DropDownList nor
BoundFields from the GridView are translated. This page runs successfully using
Microsoft .NET Framework.
Reproducible: Always
Steps to Reproduce:
1. Create a C# ASP.NET project using MonoDevelop.
2. In the Default page aspx file, add the following attribute to the <%@ Page
tag: culture="auto"
3. Inside the form runat="server" tag, put the following code:
<asp:Button id="btnEnglish" runat="server" Text="English!"
OnClick="btnEnglishClicked" />
<asp:Button id="btnEspanol" runat="server" Text="Español!"
OnClick="btnEspanolClicked" />
<asp:Label ID="lblDayOfWeek" runat="server"
meta:resourcekey="lblDayOfWeekResource1" Text="Day of week: "></asp:Label>
<asp:DropDownList ID="ddlDayOfWeek" runat="server"
meta:resourcekey="ddlDayOfWeekResource1">
<asp:ListItem
meta:resourcekey="ListItemResource1">Sunday</asp:ListItem>
<asp:ListItem
meta:resourcekey="ListItemResource2">Monday</asp:ListItem>
<asp:ListItem
meta:resourcekey="ListItemResource3">Tuesday</asp:ListItem>
<asp:ListItem
meta:resourcekey="ListItemResource4">Wednesday</asp:ListItem>
<asp:ListItem
meta:resourcekey="ListItemResource5">Thursday</asp:ListItem>
<asp:ListItem
meta:resourcekey="ListItemResource6">Friday</asp:ListItem>
<asp:ListItem
meta:resourcekey="ListItemResource7">Saturday</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="gvData" runat="server" DataSourceID="xdsData"
AutoGenerateColumns="false" >
<Columns>
<asp:BoundField DataField="name" HeaderText="Name"
meta:resourcekey="BoundFieldResource1"
SortExpression="name" />
<asp:BoundField DataField="description"
HeaderText="Description" meta:resourcekey="BoundFieldResource2"
SortExpression="description" />
</Columns>
</asp:GridView>
<asp:XmlDataSource ID="xdsData" runat="server" DataFile="~/data.xml"
XPath="/root/element" />
4. In the usings section of the page's code behind, add the following:
using System;
using System.Web;
using System.Web.UI;
using System.Globalization;
using System.Threading;
4. Inside the page class put the following code:
protected override void InitializeCulture ()
{
base.InitializeCulture ();
string lang = (string)Session["Language"];
if (lang == null)
lang = "en-US";
CultureInfo culture = new CultureInfo(lang);
this.UICulture = culture.Name;
this.Culture = culture.Name;
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
public virtual void btnEnglishClicked (object sender, EventArgs args)
{
Session["Language"] = "en-US";
Response.Redirect(Request.Url.ToString());
}
public virtual void btnEspanolClicked (object sender, EventArgs args)
{
Session["Language"] = "es-MX";
Response.Redirect(Request.Url.ToString());
}
5. Add an App_LocalResources directory in the project's root.
6. Create two or more resx files with names Default.aspx.resx and like
Default.aspx.es.resx, Default.aspx.es-MX.resx inside the created folder of step
5. Put the XML code with the required object translations, like the following
shows:
<?xml version="1.0" encoding="utf-8"?>
<root>
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0"
msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"
msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3"
/>
<xsd:attribute name="mimetype" type="xsd:string"
msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms,
Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="lblDayOfWeekResource1.Text" xml:space="preserve">
<value>Day of week: </value>
</data>
<data name="ListItemResource1.Text" xml:space="preserve">
<value>Sunday</value>
</data>
<data name="ListItemResource2.Text" xml:space="preserve">
<value>Monday</value>
</data>
<data name="ListItemResource3.Text" xml:space="preserve">
<value>Tuesday</value>
</data>
<data name="ListItemResource4.Text" xml:space="preserve">
<value>Wednesday</value>
</data>
<data name="ListItemResource5.Text" xml:space="preserve">
<value>Thursday</value>
</data>
<data name="ListItemResource6.Text" xml:space="preserve">
<value>Friday</value>
</data>
<data name="ListItemResource7.Text" xml:space="preserve">
<value>Saturday</value>
</data>
<data name="BoundFieldResource1.HeaderText" xml:space="preserve">
<value>Name</value>
</data>
<data name="BoundFieldResource2.HeaderText" xml:space="preserve">
<value>Description</value>
</data>
</root>
7. Create an XML file named data.xml to fill the gridview with some data:
<root>
<element name="John" description="administrator" />
<element name="David" description="art director" />
<element name="Anna" description="finances" />
</root>
8. Run the website in an internet browser and enter page Default.aspx.
9. Click on the language change buttons and see what happens.
Actual Results:
The pages displays fine, and when you click the buttons, the label changes the
text to the desired language, but the DropDownList (combo) and GridView still
show the items and column header in the default language (english).
Expected Results:
When you click on the buttons to change the page language, the set of items in
the DropDownList and the column headers should display text in the selected
language.
--
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
More information about the mono-bugs
mailing list