ASP.NET 元:资源密钥 [英] ASP.NET meta:resourcekey

查看:14
本文介绍了ASP.NET 元:资源密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看一个 ASP.NET 应用程序,它大量使用了似乎与 resx 文件相关联的 meta:resourcekey.

I'm looking at an ASP.NET application which makes heavy use of meta:resourcekey which seem to be connected to the resx files.

这是一个似乎完全忽略了我的区域.有人对这种方法的好处和目的以及最佳做法有任何指导吗?

This is an area that seeems to have completely passed me by. Does anyone have any guidance on the benefits and purpose of this approach and best practices?

推荐答案

meta:resourcekey 语法允许您对隐式资源表达式使用声明式语法.这在本地化站点以供国际使用时使用.正如快速入门(链接如下)所解释的,这些类型的表达式链接到位于 App_LocalResources 文件夹中的 .resx 文件.

The meta:resourcekey syntax allows you use declarative syntax for Implicit Resource expressions. This is used when localizing a site for international use. As the Quickstarts (linked below) explain, these kind of expressions are linked to .resx files located in the App_LocalResources folder.

这种表达式的好处是它可以为单个控件使用多个属性,这些属性定义在 .resx 文件中,而不是 ASPX 本身.

The benefit of this kind of expression is that it can use multiple properties for a single control which are defined in the .resx file instead of the ASPX itself.

以下面的标签为例:

<asp:Label ID="myLabel" runat="server" Text="This text is localizable" meta:resourcekey="myLabelResource1">
</asp:Label>

此页面的 resx 文件可能包含附加到标签的多个属性的数据,例如:

The resx file for this page could contain data for multiple properties attached to the label such as:

  <data name="myLabelResource1.Font-Name">
    <value xml:space="preserve">Default Font name</value>
  </data>
  <data name="myLabelResource1.Text">
    <value xml:space="preserve">Text in default language.</value>
  </data>
  <data name="myLabelResource1.ToolTip">
    <value>Tooltip in default language.</value>
  </data>

ASP.NET 快速入门如果您想了解这个概念,请先入门.

The ASP.NET quickstarts provide a great primer if you want to understand the concept.

这篇关于ASP.NET 元:资源密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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