gpt4 book ai didi

c# - 本地化与文字之间的区别

转载 作者:太空狗 更新时间:2023-10-30 00:54:44 25 4
gpt4 key购买 nike

我只是在阅读Literal 控件和Localize 之间的区别

我知道这个问题已经被问过here但那里提出的回应对我来说不起作用。

根据 MSDN:

The Localize control inherits from the Literal control and is identical to it in every way. The Localize control is used at design time to distinguish static text that can be localized from other static text.

我目前对 LocalizeLiteral 控件的理解是,前者在 Visual Studio 的设计时呈现默认值,而后者将呈现 计算值,例如资源文件的内容

我创建了一个小页面来证明这一点,但我找不到任何区别,这就是我尝试的原因:

    <div><asp:Localize ID="Localize1" Text="<%$Resources: Resource, String1 %>" runat="server" >String1</asp:Localize></div>
<div><asp:Literal ID="Literal1" Text="<%$Resources: Resource, String1 %>" runat="server" >String1</asp:Literal></div>
<div><asp:Label ID="Label1" Text="<%$Resources: Resource, String1 %>" runat="server" >String1</asp:Label></div>

以上代码呈现如下:

    <div>ploop</div>
<div>ploop</div>
<div><span id="Label1">ploop</span></div>

到目前为止一切顺利,但我希望在设计时发现 Visual Studio 中的差异,但我没有,这是 Visual Studio 输出

enter image description here

作为附加说明,我知道在处理资源时我可以使用隐式资源(在处理本地资源时),以便在设计时使用默认值。示例:

    <asp:Label ID="Label1" runat="server" meta:resourcekey="Label1Resource1" 
Text="Label"></asp:Label>

使用上面的代码,我得到了设计时在 Visual Studio 中按预期呈现的文本 Label

那么 LiteralLocalize 控件之间有什么区别?我错过了什么?

注意:我使用网站和 Web 应用程序进行了测试

最佳答案

@Jupaol,不确定你是否清楚 <asp:Localize> 到底是什么control 会,但它会将文本转换为本地语言。看看When should I use a Localize control instead of a Literal?希望这会更有意义。

关于c# - 本地化与文字之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11894198/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com