ASP.NET:显式本地化与隐式本地化?
在我看来,隐式本地化相对于显式本地化的优势在于,如果您有多个属性要针对给定控件进行本地化,那么这是一种更经济的语法。
如果您只需要本地化一些文本,我会使用 asp:Localize 控件,该控件仅具有呈现到 UI 的单个属性(文本)。有理由使用其中一种而不是另一种吗?有什么风格偏好吗?有速度差异吗?
隐式
<asp:Localize ID="Localize1" runat="server" meta:resourcekey="Something" />
与
显式
<asp:Localize ID="Localize1" runat="server" Text="<%$ Resources:Something %>" />
To my mind the advantage of implicit localization over explicit localization is that if you have more than one property to localize for a given control, it's a more economical syntax.
In the case where you just need to localize some text I use the asp:Localize control which only has a single property (Text) that renders to the UI. Is there a reason to use one over the other? Any style preference? Are there any speed differences?
Implicit
<asp:Localize ID="Localize1" runat="server" meta:resourcekey="Something" />
vs
Explicit
<asp:Localize ID="Localize1" runat="server" Text="<%$ Resources:Something %>" />
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我更喜欢显式,有时您需要对本地化的内容进行编码/解码。此外,在处理多种语言和文化时,使用 Explicit 可以让您省去麻烦。
I'm more in favor over Explicit, sometimes you need to encode/decode what you have localized. Also, when dealing with multiple languages and culture, using Explicit saves you headaches..
好吧,你的问题让我思考两者中是否有任何一个提供了编译时间错误检查。
并发现它不提供编译时检查。当给定错误的值时,这两种炸弹都会在运行时发生。
Well your question got me thinking if any of the two provides complie time error check.
And found that it dose not provide compile time check. Both bombs at run time when given wrong values.