Re:ASP.NET国际化的bug? [英] Re: ASP.NET Internationalization bug?

查看:56
本文介绍了Re:ASP.NET国际化的bug?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重新:

!我找到了一个MSDN文档,解释了为什么我要做的应该工作


Lee,


来自:
http://www.w3.org/TR/REC-xml/


"可以在文档中插入名为xml:lang的特殊属性来指定

语言在XML文档中任何元素的内容和属性值中使用。


如果有的话,我可以看到xml:lang被声明为具体内容值,例如:


< p xml:lang =" en-GB">它的颜色是什么颜色?< / p>

< p xml:lang =" en-US">它是什么颜色的?< / p>


然后,xml解析器可以识别美国和英国的区域拼写但是,鉴于*所有*属性值

必须在html文档中使用英语,为html标记声明xml:lang的目的是什么?


此处给出了类似的解释:
http:/ /www.simonstl.com/xmlprim/xmlupdate/atts.html

--- 000 ---

< SECTION>

< DESCRIPTION xml:lang =" en">

Caesar首先描述了高卢的地理位置。

< / DESCRIPTION>

< QUOTE xml:lang =" la">

Gallia est omnis divisa in partes tres,quarum unam incolnt Belgae,

aliam Aquitani,triiam qui ipsorum lingua Celtae,nostra Galli appellantur。

< / QUOTE>

--- 000 ---


这对于xml:lang来说非常好用,因为解析器可以有选择地识别不同语言的内容。


但是,在我看来,设置xml:lang for html标签''*属性*值是不需要的,因为它们必须是英语的
,并且它们必须是设置为语言的属性年龄标识符,由IETF RFC 4646定义
http://www.ietf.org/rfc/rfc4646.txt) 。


所以,我认为必不可少的确定无用

为html文档中的所有属性设置xml:lang。

如果有的话,似乎xml:lang属性包含在
$ b中$ b html服务器标签用于兼容性目的,或者可能是出于无知。


如果需要确定特定标记标记的*内容*是否在
特定语言,该标识可以包含在标签本身中,例如:


< div lang =" MX-es" xml:lang =" MX-es">

Algo de contenido en espa?ol mejicano。

< / div>


这比为html标签中的属性值设置xml:lang更有意义。

Juan T. Llibre,asp.net MVP

asp.net faq: http://asp.net.do/faq/

foros de asp.net,en espa?ol: http://asp.net.do/foros/

========================= =============

" Lee C." < no ***** @ spammer.com在消息新闻中写道:%2 **************** @ TK2MSFTNGP04.phx.gbl ...


>我找到了一个MSDN文档,解释了我为什么要做的工作。


ASP.NET Web服务器控件概述
http://msdn.microsoft.com/en -us / library / zsyt68f1.aspx

请注意文档中HTML服务器控件和Web服务器控件之间的区别。另外,请注意传递的解释

HTML服务器控件的属性。


两个引号总结:

1.页面上的任何HTML元素都可以转换为HTML服务器控件添加属性runat =" server" ;.

2.您可以将所需的任何属性添加到HTML服务器控件中,页面框架将呈现它们而不需要

任何更改在功能上。


,Lee


" Lee C." < no ***** @ spammer.com在消息新闻中写道:大江************** @ TK2MSFTNGP03.phx.gbl ...


> Juan,

我很感激你的帮助,但你错了,你就是那个困惑的人。 :]

我不*争论当以编程方式插入时,xml:lang属性呈现给浏览器。我只是做了一个解决方法(就在我发现这个bug之后);但是,我不应该这样做。

我不会*使用runat =" server"混淆html属性你称之为属性。使用您的逻辑,在我添加runat =" server"之后,没有任何
声明性(html)属性应该呈现给浏览器。在ASP.NET中;但是所有这些(xmlns,lang和dir)都做了 - 除了xml:lang。

我开始使用一个带有4个属性的html元素(xmlns,lang,xml:lang,所有以声明方式设置。使用* no *
第5个属性runat =" server",所有4个属性都会呈现。如果我添加runat =" server"的第5个属性,它不会和不应该呈现,我不再获得应该呈现的所有4个属性(xmlns,lang,xml:lang和dir),I
只获得3(xmlns,lang和dir)。我的逻辑说我应该得到4,你说我应该得到3?它将是4或0,而
4是正确的。不是0 ......而不是3.

当我添加runat =" server"时,它并没有神奇地使xml:lang属性成为服务器端属性,同时保持
其他三个属性为html属性。所有四个仍然是html属性 - 应该渲染。

我认为我的例子的简化可能让你感到困惑。奇怪的是,在我的例子中,我设置了runat =" server"
但没有任何服务器端属性。 (为简单起见,我将所有4个作为文字字符串。)嗯,在我的实际使用中,我确实有服务器端属性,我想要声明性地设置(没有代码旁边没有
脚本)。我有:

< html runat =" server" xmlns =" http://www.w3.org/1999/xhtml"
xml:lang ="<%$资源:GlobalLang,ContentAudienceLanguage%>"
lang =" <%$资源:GlobalLang,ContentAudienceLanguage%>"
dir =" ltr">

这两个声明性显式本地化表达式应该无需我不得不再写了
程序性 (代码旁边)代码或脚本。它确实对lang属性工作正常 - 因为它应该;但不是
的xml:lang属性 - ***这是一个bug ***。

,Lee

Juan T. Llibre < no *********** @ nowhere.com在消息新闻中写道:u0 ************** @ TK2MSFTNGP04.phx.gbl ...


>> re:
!我认为你是误会,Juan。

好吧,我认为你误解了我*。

重新:
!我在html标签中有声明的xml:lang属性,如下所示:
...它呈现给浏览器,因为它应该。

是的,因为它是标准的HTML。

重新:
!如果我只是添加runat =" server"

对于任何要在服务器端编程的属性,你需要一个脚本,就像你需要一个脚本来修改任何服务器控件一样'' s属性。

你是否运行了我发送的示例页面?

它遍历html服务器控件的属性,
并显示xml:lang属性*是*以编程方式添加。

重新:
!如果我只是添加runat =" server",则留在xml:lang属性
!渲染没有runat =" server",所有(声明性)属性都被渲染到浏览器 - 除了xml:lang属性!这是一个错误。

我认为你的html属性与runat =" server"混淆了属性。

Html属性可以插入普通的html。
服务器端属性必须插入代码中。

也许我不是解释这个我应该如此。
如果你不接受我的话,试着让别人对这个问题有所了解。

Juan T. Llibre,asp.net MVP
asp.net常见问题: http://asp.net.do/faq/
foros de asp.net,en espa?ol: http:// asp.net.do/foros/
================================== ====
Lee C. < no ***** @ spammer.com在留言新闻中写道:en ************** @ TK2MSFTNGP04.phx.gbl ...
我觉得你很误解,胡安。我在html标签中声明了xml:lang属性(声明性地),如下所示:

< html xmlns =" http://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">

...它会呈现给浏览器。

如果我只是添加runat =" server",则离开在没有runat =" server"的情况下呈现的xml:lang属性中,所有
(声明性)属性都呈现给浏览器 - 除了xml:lang属性!这是一个错误。

< html runat =" server"的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">

亲切地,
$

" Juan T. Llibre" < no *********** @ nowhere.com在留言新闻中写道:ey ************** @ TK2MSFTNGP02.phx.gbl ...
这是一个完整的例子,它显示了xml:lang属性是以编程方式添加的:
>
attributes.aspx:
-------------- --------
<%@ Page Language =" C#" AutoEventWireup = QUOT;真" %>
< html xmlns =" http://www.w3.org/1999/xhtml" RUNAT = QUOT;服务器" ID = QUOT; MYID" >
< script language =" C#" runat =" server">
void Page_Load(Object sender,EventArgs e)
Myid.Attributes.Add(" xml:lang"," es");
Message.InnerHtml ="< h4> html控件属性集合包含:< / h4>" ;;
IEnumerator keys = Myid.Attributes.Keys.GetEnumerator();
while (keys.MoveNext())
{
String key =(String)keys.Current;
Message.InnerHtml + = key +" =" + Myid.Attributes [key] +"< br />" ;;
}
}< / script>
< head id =" Head1" ; runat =" server">
< title> html控件属性集合< / title>
< / head>
< body>
< form id = QUOT; Form1中" runat =" server">
< h3> HtmlControl属性集合示例< / h3>
< br />
< span id ="消息"的EnableViewState = QUOT假QUOT; RUNAT = QUOT;服务器" />
< / form>
< / body>
< / html>
----------------
>
我不认为必须以编程方式添加属性,因为runat =" server"仅标记*声明* html控件作为可编程控件。
>
要实际编程,必须使用脚本。
>
>
>
>
Juan T. Llibre,asp.net MVP
asp.net faq: http://asp.net.do/faq/
foros de asp.net,en espa?ol: http://asp.net.do/foros/
=========== ===========================
Lee C. < no ***** @ spammer.com在留言新闻中写道:e0 ************** @ TK2MSFTNGP03.phx.gbl ...
>谢谢,Juan。
>>
>我已在我的母版页代码中添加了类似的代码到页面事件。
>>
> elHtml.Attributes.Add(" xml:lang",Resources.GlobalLang.ContentAudienceLanguage)
>>
>对我来说,这是一个临时的解决方法。我仍然想知道吃是否吃。我最初
>张贴的属性是一个错误,或者如果出于某种原因实际发生这种情况。
>>
>亲切地,
> Lee
>>
>>
>" Juan T. Llibre" < no *********** @ nowhere.com在消息新闻中写道:%2 **************** @ TK2MSFTNGP03.phx.gbl ...
>>李。
>>>
>> re:
>>!< html runat =" server"的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">
>>!没有xml:lang属性呈现给浏览器!
>>!删除runat =" server",瞧,呈现xml:lang属性。
>>>
>>试试这个:
>>>
>>< html的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" RUNAT = QUOT;服务器" id =" someID">
>>>
>>< script runat =" server">
>> someID.Attributes(" ; xml:lang")=" zh-CN"
>>< / script>
>>>
>>>
>>>
>> Juan T. Llibre,asp.net MVP
>> asp.net faq: http://asp.net.do/faq/
>> foros de asp.net,en espa?ol: http://asp.net.do/foros/
> ;> ======================================
>>> ;
>>" Lee C." < no **** @ spam.com在消息新闻中写道:O%**************** @ TK2MSFTNGP03.phx.gbl ...
>> >>我想我在ASP.NET中发现了一个与I18N相关的错误。
>>>>
>>>在ASP.NET 3.5中,我必须set runat =" server"在html元素上使用显式表达式。当设置为runat =" server"时,似乎
>>> ASP.NET
>>>会在html元素上吃xml:lang属性。 />>>>>
>>>当然我想要替换硬编码的en-US。带有(资源)显式表达式的值;但是,对于
>>>简单,
>>>试试这个:
>>>>
>>> < html runat =" server"的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">
>>>>
>>> ...您会发现没有xml:lang属性呈现给浏览器!删除runat =" server"和
>>>瞧,
>>>
>>>> xml:lang属性呈现。 :[
>>>>
>>> ...任何想法?
>>>>
>> >亲切地,
>>> Lee
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>




解决方案

< blockquote>资源:GlobalLang,ContentAudienceLanguage%>"
lang ="<%


资源:GlobalLang,ContentAudienceLanguage%>"
dir = ltr>

这两个声明性显式本地化表达式应该可以工作,而不必再写
程序性的 (代码旁边)代码或脚本。它确实对lang属性工作正常 - 因为它应该;但不是
的xml:lang属性 - ***这是一个bug ***。

,Lee

Juan T. Llibre < no *********** @ nowhere.com在消息新闻中写道:u0 ************** @ TK2MSFTNGP04.phx.gbl ...


>> re:
!我认为你是误会,Juan。

好吧,我认为你误解了我*。

重新:
!我在html标签中有声明的xml:lang属性,如下所示:
...它呈现给浏览器,因为它应该。

是的,因为它是标准的HTML。

重新:
!如果我只是添加runat =" server"

对于任何要在服务器端编程的属性,你需要一个脚本,就像你需要一个脚本来修改任何服务器控件一样'' s属性。

你是否运行了我发送的示例页面?

它遍历html服务器控件的属性,
并显示xml:lang属性*是*以编程方式添加。

重新:
!如果我只是添加runat =" server",则留在xml:lang属性
!渲染没有runat =" server",所有(声明性)属性都被渲染到浏览器 - 除了xml:lang属性!这是一个错误。

我认为你的html属性与runat =" server"混淆了属性。

Html属性可以插入普通的html。
服务器端属性必须插入代码中。

也许我不是解释这个我应该如此。
如果你不接受我的话,试着让别人对这个问题有所了解。

Juan T. Llibre,asp.net MVP
asp.net常见问题: http://asp.net.do/faq/
foros de asp.net,en espa?ol: http:// asp.net.do/foros/
================================== ====
Lee C. < no ***** @ spammer.com在留言新闻中写道:en ************** @ TK2MSFTNGP04.phx.gbl ...
我觉得你很误解,胡安。我在html标签中声明了xml:lang属性(声明性地),如下所示:

< html xmlns =" http://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">

...它会呈现给浏览器。

如果我只是添加runat =" server",则离开在没有runat =" server"的情况下呈现的xml:lang属性中,所有
(声明性)属性都呈现给浏览器 - 除了xml:lang属性!这是一个错误。

< html runat =" server"的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">

亲切地,
$

" Juan T. Llibre" < no *********** @ nowhere.com在留言新闻中写道:ey ************** @ TK2MSFTNGP02.phx.gbl ...
这是一个完整的例子,它显示了xml:lang属性是以编程方式添加的:
>
attributes.aspx:
-------------- --------
<%@ Page Language =" C#" AutoEventWireup = QUOT;真" %>
< html xmlns =" http://www.w3.org/1999/xhtml" RUNAT = QUOT;服务器" ID = QUOT; MYID" >
< script language =" C#" runat =" server">
void Page_Load(Object sender,EventArgs e)
Myid.Attributes.Add(" xml:lang"," es");
Message.InnerHtml ="< h4> html控件属性集合包含:< / h4>" ;;
IEnumerator keys = Myid.Attributes.Keys.GetEnumerator();
while (keys.MoveNext())
{
String key =(String)keys.Current;
Message.InnerHtml + = key +" =" + Myid.Attributes [key] +"< br />" ;;
}
}< / script>
< head id =" Head1" ; runat =" server">
< title> html控件属性集合< / title>
< / head>
< body>
< form id = QUOT; Form1中" runat =" server">
< h3> HtmlControl属性集合示例< / h3>
< br />
< span id ="消息"的EnableViewState = QUOT假QUOT; RUNAT = QUOT;服务器" />
< / form>
< / body>
< / html>
----------------
>
我不认为必须以编程方式添加属性,因为runat =" server"仅标记*声明* html控件作为可编程控件。
>
要实际编程,必须使用脚本。
>
>
>
>
Juan T. Llibre,asp.net MVP
asp.net faq: http://asp.net.do/faq/
foros de asp.net,en espa?ol: http://asp.net.do/foros/
=========== ===========================
Lee C. < no ***** @ spammer.com在留言新闻中写道:e0 ************** @ TK2MSFTNGP03.phx.gbl ...
>谢谢,Juan。
>>
>我已在我的母版页代码中添加了类似的代码到页面事件。
>>
> elHtml.Attributes.Add(" xml:lang",Resources.GlobalLang.ContentAudienceLanguage)
>>
>对我来说,这是一个临时的解决方法。我仍然想知道吃是否吃。我最初
>张贴的属性是一个错误,或者如果出于某种原因实际发生这种情况。
>>
>亲切地,
> Lee
>>
>>
>" Juan T. Llibre" < no *********** @ nowhere.com在消息新闻中写道:%2 **************** @ TK2MSFTNGP03.phx.gbl ...
>>李。
>>>
>> re:
>>!< html runat =" server"的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">
>>!没有xml:lang属性呈现给浏览器!
>>!删除runat =" server",瞧,呈现xml:lang属性。
>>>
>>试试这个:
>>>
>>< html的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" RUNAT = QUOT;服务器" id =" someID">
>>>
>>< script runat =" server">
>> someID.Attributes(" ; xml:lang")=" zh-CN"
>>< / script>
>>>
>>>
>>>
>> Juan T. Llibre,asp.net MVP
>> asp.net faq: http://asp.net.do/faq/
>> foros de asp.net,en espa?ol: http://asp.net.do/foros/
> ;> ======================================
>>> ;
>>" Lee C." < no **** @ spam.com在消息新闻中写道:O%**************** @ TK2MSFTNGP03.phx.gbl ...
>> >>我想我在ASP.NET中发现了一个与I18N相关的错误。
>>>>
>>>在ASP.NET 3.5中,我必须set runat =" server"在html元素上使用显式表达式。当设置为runat =" server"时,似乎
>>> ASP.NET
>>>会在html元素上吃xml:lang属性。 />>>>>
>>>当然我想要替换硬编码的en-US。带有(资源)显式表达式的值;但是,对于
>>>简单,
>>>试试这个:
>>>>
>>> < html runat =" server"的xmlns = QUOT; HTTP://www.w3.org/1999/xhtml" XML:朗= QUOT;的en-US"郎= QUOT;的en-US" dir =" ltr">
>>>>
>>> ...您会发现没有xml:lang属性呈现给浏览器!删除runat =" server"和
>>>瞧,
>>>
>>>> xml:lang属性呈现。 :[
>>>>
>>> ...任何想法?
>>>>
>> >亲切地,
>>> Lee
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>





Juan,
练习中,它经常出现严重问题。首先,你指的是XML标准,而不是HTML和XHTML

标准。其次,他们中没有一个人能够清楚地了解最佳实践。

I18N。有很多* legal *(按标准)语法,没有感觉,或者说没有明显最好的感觉。 W3C网站通常会说明某些事情的效果,有些人正在这样做,有些人在做你自己的网站,至少做一些事情时间将告诉我们什么是最好的。


在W3C网站上查看这些反映我的语法的精彩示例。


国际化最佳实践:在XHTML中指定语言& HTML

内容
http://www.w3.org/TR/i18n-html-tech-...0429.092928424

教程:使用XHTML和HTML(草稿)声明语言
http:// www.w3.org/International/tuto...Slide0160.html


Juan,您写道:


但是,在我看来,为html标签的'*属性*

值设置xml:lang是不必要的,因为它们必须是

是英文的,并且它们必须是设置为语言标识符的属性,如IETF RFC 4646定义的

http://www.ietf.org/rfc/rfc4646.txt) 。



你没有为标签的*属性*设置它,你要为
$设置它b $ b * contents *,元素的所有内容(除非被

子设置覆盖),这非常有意义,所以我不必设置它
每个子元素单独
- 这是层次结构的力量!你好b / b
似乎专注于技术,有一些误解,而不是我们想要完成的

精神:告诉用户代理我们的

目标受众是按语言,尽我们所能...这就是为什么我* * * * * *
在HTTP标头和页面元标记中设置lang。


,Lee

" Juan T. Llibre" < no *********** @ nowhere.comwrote in message

news:OY ************** @ TK2MSFTNGP02.phx。 gbl ...


re:

!我找到了一个MSDN文档,解释了为什么我要做的应该

工作


Lee,


来自:
http://www.w3.org/TR/REC-xml/


"一个名为xml:lang的特殊属性可以插入文件中

指定

语言中使用的内容和属性值

XML文档中的任何元素。


如果有的话,我可以看到为特定内容声明xml:lang

值,例如:


< p xml:lang =" en-GB">它的颜色是什么颜色?< / p>

< p xml:lang =" en-US">它是什么颜色的?< / p>


然后,xml解析器可以识别美国和英国的区域h拼写但是,

假设*所有*属性值

必须是html doc中的英文,宣布
$ b的目的是什么$ b xml:lang用于html标记?


此处给出了类似的解释:
http://www.simonstl.com/xmlprim/xmlupdate/atts.html


--- 000 ---

< SECTION>

< DESCRIPTION xml:lang =" en">

Caesar开始通过描述高卢的地理位置。

< / DESCRIPTION>

< QUOTE xml:lang =" la">

Gallia est omnis divisa in partes tres,quarum unam incolunt Belgae,

aliam Aquitani,tertiam qui ipsorum lingua Celtae,nostra Galli

appellantur。

< ; / QUOTE>

--- 000 ---


这对于xml:lang来说非常好用,因为解析器可以选择性地

识别竞争nt用不同的语言。


但是,在我看来,不需要为html标签''*属性*

值设置xml:lang,因为它们必须是英文的b $ b,并且它们必须是设置为语言标识符的属性,如IETF RFC 4646定义的


(< a rel =nofollowhref =http://www.ietf.org/rfc/rfc4646.txt)\"target =_ blank> http://www.ietf.org/rfc/rfc4646.txt)。


所以,我认为必不可少的确定了为html文档中的所有属性设置xml:lang的徒劳无功

。 />

如果有的话,似乎xml:lang属性包含在

html服务器标签中以用于兼容性目的,或者可能是出于无知。


如果需要确定特定标记

标记的*内容*是否使用特定语言,那么该标识可以包含在标签本身,

例如:


< div lang =" MX-es" xml:lang =" MX-es">

Algo de contenido en espa?ol mejicano。

< / div>


这比在html标签中为属性值

设置xml:lang更有意义。


Juan T. Llibre,asp .net MVP

asp.net faq: http:// asp .net.do / faq /

foros de asp.net,en espa?ol: http://asp.net.do/foros/

================= =====================

" Lee C." < no ***** @ spammer.comwrote in message

news:%2 **************** @ TK2MSFTNGP04.phx.gbl .. 。


>>我找到了一个MSDN文档,解释了为什么我要做的应该工作。

ASP.NET Web服务器控件概述
http ://msdn.microsoft.com/en-us/library/zsyt68f1.aspx

Note the distinction between HTML Server Controls and Web Server Controls
in the document. Also, note the explanation
of "pass-through" attributes for HTML Server Controls.

Two quotes that sum it up:
1. Any HTML element on a page can be converted to an HTML server
control by adding the attribute runat="server".
2. You can add any attributes you need to an HTML server control and
the page framework will render them without
any change in functionality.

, Lee

"Lee C." <no*****@spammer.comwrote in message
news:Oe**************@TK2MSFTNGP03.phx.gbl...
\t

\t
\t\t\t\t>>Juan,

I appreciate your trying to help, but you’’re wrong, and you are the one
who is confused. :]

I am *not* disputing that when inserted programmatically, the xml:lang
attribute renders to the browser. I did just
that as a work around (right after I discovered this bug); but, I should
not have to.

I am *not* confusing html attributes with runat="server" attributes, as
you call them. Using your logic, none of the
declarative (html) attributes should render to the browser after I add
the runat="server" in ASP.NET; yet all of them
(xmlns, lang, and dir) do--except xml:lang.

I started with an html element with 4 attributes (xmlns, lang, xml:lang,
and dir) all set declaratively. With *no*
5th attribute of runat="server", all 4 attributes render. If I add the
5th attribute of runat="server", which does
not and should not render, I no longer get all 4 attributes that should
render (xmlns, lang, xml:lang, and dir), I
only get 3 (xmlns, lang, and dir). My logic says I should get 4, your
says I should get 3? It would be 4 or 0, and
4 is right. Not 0...and not 3.

When I add runat="server", it does not magically make the xml:lang
attribute a server-side attribute, while keeping
the other three attributes as "html"属性。 All four are still
"html" attributes--which should render.

I think the simplification of my example may be confusing you. It is
odd that, in my example, I set runat="server"
but do not have any server-side attributes. (I have all 4 as literal
strings, for simplicity of an example.) Well,
in my real-world use, I do have server-side attributes, which I want set
declaratively (no code-beside and no
script). I have:

<html runat="server" xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<%


re:
!I found an MSDN document that explains why what I''m trying to do should work

Lee,

From :

http://www.w3.org/TR/REC-xml/

"A special attribute named xml:lang may be inserted in documents to specify the
language used in the contents and attribute values of any element in an XML document."

If anything, I can see xml:lang being declared for specific content values, for example :

<p xml:lang="en-GB">What colour is it?</p>
<p xml:lang="en-US">What color is it?</p>

Then, an xml parser could identify regional US and British spellings but, given that *all* the attribute values
must be in English in an html doc, what would be the purpose of declaring xml:lang for the html markup ?

A similar explanation is given here :
http://www.simonstl.com/xmlprim/xmlupdate/atts.html

---000---
<SECTION>
<DESCRIPTION xml:lang="en">
Caesar begins by describing the geography of Gaul.
</DESCRIPTION>
<QUOTE xml:lang="la">
Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae,
aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli appellantur.
</QUOTE>
---000---

That''s perfectly good usage for xml:lang, as a parser could selectively identify content in different languages.

But, it seems to me that setting xml:lang for the html tag''s *attribute* values is unneeded, since they must
be in English, and they must be attributes set to a language identifier, as defined by IETF RFC 4646
(http://www.ietf.org/rfc/rfc4646.txt).

So, I think that requisite pretty well establishes the futility
of setting xml:lang for all the attributes in an html document.

If anything, it seems that the xml:lang attribute is included in the
html server tag for compatibility purposes, or perhaps out of ignorance.

If there''s a need to identify that the *contents* of a particular markup tag are in a
specific language, that identification can be included in the tag itself, for example :

<div lang="MX-es" xml:lang="MX-es">
Algo de contenido en espa?ol mejicano.
</div>

That makes a lot more sense than setting xml:lang for the attribute values in the html tag.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Lee C." <no*****@spammer.comwrote in message news:%2****************@TK2MSFTNGP04.phx.gbl...

>I found an MSDN document that explains why what I''m trying to do should work.

ASP.NET Web Server Controls Overview
http://msdn.microsoft.com/en-us/library/zsyt68f1.aspx

Note the distinction between HTML Server Controls and Web Server Controls in the document. Also, note the explanation
of "pass-through" attributes for HTML Server Controls.

Two quotes that sum it up:
1. Any HTML element on a page can be converted to an HTML server control by adding the attribute runat="server".
2. You can add any attributes you need to an HTML server control and the page framework will render them without
any change in functionality.

, Lee

"Lee C." <no*****@spammer.comwrote in message news:Oe**************@TK2MSFTNGP03.phx.gbl...

>Juan,

I appreciate your trying to help, but you''re wrong, and you are the one who is confused. :]

I am *not* disputing that when inserted programmatically, the xml:lang attribute renders to the browser. I did just
that as a work around (right after I discovered this bug); but, I should not have to.

I am *not* confusing html attributes with runat="server" attributes, as you call them. Using your logic, none of the
declarative (html) attributes should render to the browser after I add the runat="server" in ASP.NET; yet all of them
(xmlns, lang, and dir) do--except xml:lang.

I started with an html element with 4 attributes (xmlns, lang, xml:lang, and dir) all set declaratively. With *no*
5th attribute of runat="server", all 4 attributes render. If I add the 5th attribute of runat="server", which does
not and should not render, I no longer get all 4 attributes that should render (xmlns, lang, xml:lang, and dir), I
only get 3 (xmlns, lang, and dir). My logic says I should get 4, your says I should get 3? It would be 4 or 0, and
4 is right. Not 0...and not 3.

When I add runat="server", it does not magically make the xml:lang attribute a server-side attribute, while keeping
the other three attributes as "html" attributes. All four are still "html" attributes--which should render.

I think the simplification of my example may be confusing you. It is odd that, in my example, I set runat="server"
but do not have any server-side attributes. (I have all 4 as literal strings, for simplicity of an example.) Well,
in my real-world use, I do have server-side attributes, which I want set declaratively (no code-beside and no
script). I have:

<html runat="server" xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<%$ Resources:GlobalLang, ContentAudienceLanguage %>"
lang="<%$ Resources:GlobalLang, ContentAudienceLanguage %>"
dir="ltr">

Both of those declarative explicit localization expressions should work without my having to write any more
"procedural" (code-beside) code or script. It actually does work fine for the lang attribute--as it should; but not
for the xml:lang attribute--***which is a bug***.

, Lee

"Juan T. Llibre" <no***********@nowhere.comwrote in message news:u0**************@TK2MSFTNGP04.phx.gbl...

>>re:
!I think you are misunderstanding, Juan.

Well, I think you are misunderstanding *me*.

re:
!I had the xml:lang attribute in the html tag (declaratively), like this:
...and it renders to the browser, as it should.

Yes, because it''s standard html.

re:
!If I simply add runat="server"

That declares the control to run server side.

For any attribute to be programmed server-side you need a script,
just as you need a script to modify any server control''s attributes.

Did you run the sample page I sent ?

It iterates throught the attributes for the html server control,
and shows that the xml:lang attribute *is* added programmatically.

re:
!If I simply add runat="server", leaving in the xml:lang attribute that
!renders without runat="server", all of the (declarative) attributes are
!rendered to the browser--except the xml:lang attribute! That is a bug.

I think you''re confusing html attributes with runat="server" attributes.

Html attributes can be inserted in normal html.
Server-side attributes must be inserted in code.

Maybe I''m not explaining this as well as I should.
Try to get someone else''s opinion on this matter, if you don''t accept mine.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Lee C." <no*****@spammer.comwrote in message news:en**************@TK2MSFTNGP04.phx.gbl...
I think you are misunderstanding, Juan. I had the xml:lang attribute in the html tag (declaratively), like this:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">

...and it renders to the browser, as it should.

If I simply add runat="server", leaving in the xml:lang attribute that renders without runat="server", all of the
(declarative) attributes are rendered to the browser--except the xml:lang attribute! That is a bug.

<html runat="server" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">

Cordially,
Lee
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:ey**************@TK2MSFTNGP02.phx.gbl...
Here''s a full example which shows that the xml:lang attribute is added programmatically :
>
attributes.aspx:
----------------------
<%@ Page Language="C#" AutoEventWireup="True" %>
<html xmlns="http://www.w3.org/1999/xhtml" runat="server" id="Myid" >
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
Myid.Attributes.Add("xml:lang", "es");
Message.InnerHtml = "<h4>The html control attributes collection contains:</h4>";
IEnumerator keys = Myid.Attributes.Keys.GetEnumerator();
while (keys.MoveNext())
{
String key = (String)keys.Current;
Message.InnerHtml += key + "=" + Myid.Attributes[key] + "<br />";
}
}
</script>
<head id="Head1" runat="server">
<title>The html control attributes collection</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>HtmlControl Attribute Collection Example</h3>
<br />
<span id="Message" enableviewstate="false" runat="server" />
</form>
</body>
</html>
----------------
>
I don''t think it''s a bug to have to add an attribute programmatically,
because the runat="server" tag only *declares* the html control as a programmable control.
>
To actually program it, you must use a script.
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Lee C." <no*****@spammer.comwrote in message news:e0**************@TK2MSFTNGP03.phx.gbl...
>Thanks, Juan.
>>
>I already added similar code to a page event in my masterpage code-beside.
>>
> elHtml.Attributes.Add("xml:lang", Resources.GlobalLang.ContentAudienceLanguage)
>>
>To me, that is a temporary workaround. I still want to understand whether the "eating" of the attribute I
>originally
>posted about is a bug, or if this is actually happening for a reason.
>>
>Cordially,
>Lee
>>
>>
>"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Hi, Lee.
>>>
>>re:
>>!<html runat="server" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
>>!no xml:lang attribute is rendered to the browser!
>>!Remove the runat="server", and, voila, the xml:lang attribute is rendered.
>>>
>>Try this :
>>>
>><html xmlns="http://www.w3.org/1999/xhtml" runat="server" id="someID">
>>>
>><script runat="server">
>>someID.Attributes("xml:lang") = "en-US"
>></script>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en espa?ol : http://asp.net.do/foros/
>>======================================
>>>
>>"Lee C." <no****@spam.comwrote in message news:O%****************@TK2MSFTNGP03.phx.gbl...
>>>>I think I have discovered a bug in ASP.NET, related to I18N.
>>>>
>>>In ASP.NET 3.5 I have to set runat="server" on the html element to use explicit expressions. It appears that
>>>ASP.NET
>>>eats the xml:lang attribute on the html element when it is set to runat="server".
>>>>
>>>Of course I want to replace the hardcoded "en-US" values with (resource) explicit expressions; but, for
>>>simplicity,
>>>try this:
>>>>
>>><html runat="server" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
>>>>
>>>...And you will find that no xml:lang attribute is rendered to the browser! Remove the runat="server", and,
>>>voila,
>>>the
>>>xml:lang attribute is rendered. :[
>>>>
>>>...Any ideas?
>>>>
>>>Cordially,
>>>Lee
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>




解决方案

Resources:GlobalLang, ContentAudienceLanguage %>"
lang="<%


Resources:GlobalLang, ContentAudienceLanguage %>"
dir="ltr">

Both of those declarative explicit localization expressions should work without my having to write any more
"procedural" (code-beside) code or script. It actually does work fine for the lang attribute--as it should; but not
for the xml:lang attribute--***which is a bug***.

, Lee

"Juan T. Llibre" <no***********@nowhere.comwrote in message news:u0**************@TK2MSFTNGP04.phx.gbl...

>>re:
!I think you are misunderstanding, Juan.

Well, I think you are misunderstanding *me*.

re:
!I had the xml:lang attribute in the html tag (declaratively), like this:
...and it renders to the browser, as it should.

Yes, because it''s standard html.

re:
!If I simply add runat="server"

That declares the control to run server side.

For any attribute to be programmed server-side you need a script,
just as you need a script to modify any server control''s attributes.

Did you run the sample page I sent ?

It iterates throught the attributes for the html server control,
and shows that the xml:lang attribute *is* added programmatically.

re:
!If I simply add runat="server", leaving in the xml:lang attribute that
!renders without runat="server", all of the (declarative) attributes are
!rendered to the browser--except the xml:lang attribute! That is a bug.

I think you''re confusing html attributes with runat="server" attributes.

Html attributes can be inserted in normal html.
Server-side attributes must be inserted in code.

Maybe I''m not explaining this as well as I should.
Try to get someone else''s opinion on this matter, if you don''t accept mine.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Lee C." <no*****@spammer.comwrote in message news:en**************@TK2MSFTNGP04.phx.gbl...
I think you are misunderstanding, Juan. I had the xml:lang attribute in the html tag (declaratively), like this:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">

...and it renders to the browser, as it should.

If I simply add runat="server", leaving in the xml:lang attribute that renders without runat="server", all of the
(declarative) attributes are rendered to the browser--except the xml:lang attribute! That is a bug.

<html runat="server" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">

Cordially,
Lee
"Juan T. Llibre" <no***********@nowhere.comwrote in message news:ey**************@TK2MSFTNGP02.phx.gbl...
Here''s a full example which shows that the xml:lang attribute is added programmatically :
>
attributes.aspx:
----------------------
<%@ Page Language="C#" AutoEventWireup="True" %>
<html xmlns="http://www.w3.org/1999/xhtml" runat="server" id="Myid" >
<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs e)
{
Myid.Attributes.Add("xml:lang", "es");
Message.InnerHtml = "<h4>The html control attributes collection contains:</h4>";
IEnumerator keys = Myid.Attributes.Keys.GetEnumerator();
while (keys.MoveNext())
{
String key = (String)keys.Current;
Message.InnerHtml += key + "=" + Myid.Attributes[key] + "<br />";
}
}
</script>
<head id="Head1" runat="server">
<title>The html control attributes collection</title>
</head>
<body>
<form id="Form1" runat="server">
<h3>HtmlControl Attribute Collection Example</h3>
<br />
<span id="Message" enableviewstate="false" runat="server" />
</form>
</body>
</html>
----------------
>
I don''t think it''s a bug to have to add an attribute programmatically,
because the runat="server" tag only *declares* the html control as a programmable control.
>
To actually program it, you must use a script.
>
>
>
>
Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Lee C." <no*****@spammer.comwrote in message news:e0**************@TK2MSFTNGP03.phx.gbl...
>Thanks, Juan.
>>
>I already added similar code to a page event in my masterpage code-beside.
>>
> elHtml.Attributes.Add("xml:lang", Resources.GlobalLang.ContentAudienceLanguage)
>>
>To me, that is a temporary workaround. I still want to understand whether the "eating" of the attribute I
>originally
>posted about is a bug, or if this is actually happening for a reason.
>>
>Cordially,
>Lee
>>
>>
>"Juan T. Llibre" <no***********@nowhere.comwrote in message news:%2****************@TK2MSFTNGP03.phx.gbl...
>>Hi, Lee.
>>>
>>re:
>>!<html runat="server" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
>>!no xml:lang attribute is rendered to the browser!
>>!Remove the runat="server", and, voila, the xml:lang attribute is rendered.
>>>
>>Try this :
>>>
>><html xmlns="http://www.w3.org/1999/xhtml" runat="server" id="someID">
>>>
>><script runat="server">
>>someID.Attributes("xml:lang") = "en-US"
>></script>
>>>
>>>
>>>
>>Juan T. Llibre, asp.net MVP
>>asp.net faq : http://asp.net.do/faq/
>>foros de asp.net, en espa?ol : http://asp.net.do/foros/
>>======================================
>>>
>>"Lee C." <no****@spam.comwrote in message news:O%****************@TK2MSFTNGP03.phx.gbl...
>>>>I think I have discovered a bug in ASP.NET, related to I18N.
>>>>
>>>In ASP.NET 3.5 I have to set runat="server" on the html element to use explicit expressions. It appears that
>>>ASP.NET
>>>eats the xml:lang attribute on the html element when it is set to runat="server".
>>>>
>>>Of course I want to replace the hardcoded "en-US" values with (resource) explicit expressions; but, for
>>>simplicity,
>>>try this:
>>>>
>>><html runat="server" xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US" dir="ltr">
>>>>
>>>...And you will find that no xml:lang attribute is rendered to the browser! Remove the runat="server", and,
>>>voila,
>>>the
>>>xml:lang attribute is rendered. :[
>>>>
>>>...Any ideas?
>>>>
>>>Cordially,
>>>Lee
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>





Juan,

In theory, I like your idea of investigating "the standard"; but, in
practice it has serious problems, as it often does. First, you are
referring to the XML standard, which is not as appropriate as HTML and XHTML
standards. Second, none of them are crystal clear on best practices for
I18N. There is a lot of *legal* (by the standard) syntax, that makes no
sense, or makes some sense without being clearly best. The W3C site often
states something to the effect of, "some are doing this, some are doing
that, on your own site, at least do something and only time will tell what
is best."

Check out these fine examples, which mirror my syntax, on the W3C site.

Internationalization Best Practices: Specifying Language in XHTML & HTML
Content
http://www.w3.org/TR/i18n-html-tech-...0429.092928424
Tutorial: Declaring Language in XHTML and HTML (Draft)
http://www.w3.org/International/tuto...Slide0160.html

Juan, you wrote:

But, it seems to me that setting xml:lang for the html tag''s *attribute*
values is unneeded, since they must
be in English, and they must be attributes set to a language identifier,
as defined by IETF RFC 4646
(http://www.ietf.org/rfc/rfc4646.txt).

You''re not setting it for "the tag''s *attribute*", you''re setting it for the
*contents*, all contents, of the element (unless overridden by a
sub-setting), which makes perfect sense so that I don''t have to set it
individually on every child element--that is the power of a hierarchy! You
seem to be focused on the technical, with some misunderstanding, versus the
spirit of what we''re trying to accomplish: telling user agents who our
intended audiences is, by language, as best we can...which is why I''m *also*
setting lang in the HTTP headers and in page meta tags.

, Lee
"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:OY**************@TK2MSFTNGP02.phx.gbl...

re:
!I found an MSDN document that explains why what I''m trying to do should
work

Lee,

From :

http://www.w3.org/TR/REC-xml/

"A special attribute named xml:lang may be inserted in documents to
specify the
language used in the contents and attribute values of any element in an
XML document."

If anything, I can see xml:lang being declared for specific content
values, for example :

<p xml:lang="en-GB">What colour is it?</p>
<p xml:lang="en-US">What color is it?</p>

Then, an xml parser could identify regional US and British spellings but,
given that *all* the attribute values
must be in English in an html doc, what would be the purpose of declaring
xml:lang for the html markup ?

A similar explanation is given here :
http://www.simonstl.com/xmlprim/xmlupdate/atts.html

---000---
<SECTION>
<DESCRIPTION xml:lang="en">
Caesar begins by describing the geography of Gaul.
</DESCRIPTION>
<QUOTE xml:lang="la">
Gallia est omnis divisa in partes tres, quarum unam incolunt Belgae,
aliam Aquitani, tertiam qui ipsorum lingua Celtae, nostra Galli
appellantur.
</QUOTE>
---000---

That''s perfectly good usage for xml:lang, as a parser could selectively
identify content in different languages.

But, it seems to me that setting xml:lang for the html tag''s *attribute*
values is unneeded, since they must
be in English, and they must be attributes set to a language identifier,
as defined by IETF RFC 4646
(http://www.ietf.org/rfc/rfc4646.txt).

So, I think that requisite pretty well establishes the futility
of setting xml:lang for all the attributes in an html document.

If anything, it seems that the xml:lang attribute is included in the
html server tag for compatibility purposes, or perhaps out of ignorance.

If there''s a need to identify that the *contents* of a particular markup
tag are in a
specific language, that identification can be included in the tag itself,
for example :

<div lang="MX-es" xml:lang="MX-es">
Algo de contenido en espa?ol mejicano.
</div>

That makes a lot more sense than setting xml:lang for the attribute values
in the html tag.

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en espa?ol : http://asp.net.do/foros/
======================================
"Lee C." <no*****@spammer.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...

>>I found an MSDN document that explains why what I''m trying to do should
work.

ASP.NET Web Server Controls Overview
http://msdn.microsoft.com/en-us/library/zsyt68f1.aspx

Note the distinction between HTML Server Controls and Web Server Controls
in the document. Also, note the explanation
of "pass-through" attributes for HTML Server Controls.

Two quotes that sum it up:
1. Any HTML element on a page can be converted to an HTML server
control by adding the attribute runat="server".
2. You can add any attributes you need to an HTML server control and
the page framework will render them without
any change in functionality.

, Lee

"Lee C." <no*****@spammer.comwrote in message
news:Oe**************@TK2MSFTNGP03.phx.gbl...

>>Juan,

I appreciate your trying to help, but you''re wrong, and you are the one
who is confused. :]

I am *not* disputing that when inserted programmatically, the xml:lang
attribute renders to the browser. I did just
that as a work around (right after I discovered this bug); but, I should
not have to.

I am *not* confusing html attributes with runat="server" attributes, as
you call them. Using your logic, none of the
declarative (html) attributes should render to the browser after I add
the runat="server" in ASP.NET; yet all of them
(xmlns, lang, and dir) do--except xml:lang.

I started with an html element with 4 attributes (xmlns, lang, xml:lang,
and dir) all set declaratively. With *no*
5th attribute of runat="server", all 4 attributes render. If I add the
5th attribute of runat="server", which does
not and should not render, I no longer get all 4 attributes that should
render (xmlns, lang, xml:lang, and dir), I
only get 3 (xmlns, lang, and dir). My logic says I should get 4, your
says I should get 3? It would be 4 or 0, and
4 is right. Not 0...and not 3.

When I add runat="server", it does not magically make the xml:lang
attribute a server-side attribute, while keeping
the other three attributes as "html" attributes. All four are still
"html" attributes--which should render.

I think the simplification of my example may be confusing you. It is
odd that, in my example, I set runat="server"
but do not have any server-side attributes. (I have all 4 as literal
strings, for simplicity of an example.) Well,
in my real-world use, I do have server-side attributes, which I want set
declaratively (no code-beside and no
script). I have:

<html runat="server" xmlns="http://www.w3.org/1999/xhtml"
xml:lang="<%


这篇关于Re:ASP.NET国际化的bug?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆