[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



           Summary: DropDownList items and GridView columns don't
    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:
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" 
        <asp:GridView ID="gvData" runat="server" DataSourceID="xdsData"
AutoGenerateColumns="false" >
                <asp:BoundField DataField="name" HeaderText="Name"
                            SortExpression="name" />
                <asp:BoundField DataField="description"
HeaderText="Description" meta:resourcekey="BoundFieldResource2"
                    SortExpression="description" />
        <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";

public virtual void btnEspanolClicked (object sender, EventArgs args)
    Session["Language"] = "es-MX";

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

<?xml version="1.0" encoding="utf-8"?>
  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
    <xsd:element name="root" msdata:IsDataSet="true">
        <xsd:choice maxOccurs="unbounded">
          <xsd:element name="metadata">
                <xsd:element name="value" type="xsd:string" minOccurs="0" />
              <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:element name="assembly">
              <xsd:attribute name="alias" type="xsd:string" />
              <xsd:attribute name="name" type="xsd:string" />
          <xsd:element name="data">
                <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: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:element name="resheader">
                <xsd:element name="value" type="xsd:string" minOccurs="0"
msdata:Ordinal="1" />
              <xsd:attribute name="name" type="xsd:string" use="required" />
  <resheader name="resmimetype">
  <resheader name="version">
  <resheader name="reader">
    <value>System.Resources.ResXResourceReader, System.Windows.Forms,
Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  <resheader name="writer">
    <value>System.Resources.ResXResourceWriter, System.Windows.Forms,
Version=, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  <data name="lblDayOfWeekResource1.Text" xml:space="preserve">
    <value>Day of week: </value>
  <data name="ListItemResource1.Text" xml:space="preserve">
  <data name="ListItemResource2.Text" xml:space="preserve">
  <data name="ListItemResource3.Text" xml:space="preserve">
  <data name="ListItemResource4.Text" xml:space="preserve">
  <data name="ListItemResource5.Text" xml:space="preserve">
  <data name="ListItemResource6.Text" xml:space="preserve">
  <data name="ListItemResource7.Text" xml:space="preserve">
  <data name="BoundFieldResource1.HeaderText" xml:space="preserve">
  <data name="BoundFieldResource2.HeaderText" xml:space="preserve">

7. Create an XML file named data.xml to fill the gridview with some data:

    <element name="John" description="administrator" />
    <element name="David" description="art director" />
    <element name="Anna" description="finances" />

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

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