本地化 WebForms,但不过度使用 meta:resourcekey
我刚刚收到一个需要本地化的项目。
我刚刚遇到了 meta:resourcekey 以及它如何与本地资源文件结合使用。
我的问题是:我必须这样做吗?
考虑一下 MSDN 上的这个例子:
<asp:Button ID="Button1" runat="server" Text="DefaultText"
meta:resourcekey="Button1" />
如果我是第一次阅读这篇文章(我也是),我会说“为什么要指定 Button1
两次?”
如果<@ Page @>
已经把Culture
设置为auto
,并且有本地资源文件,就去找各个控件的本地资源,如果有的话,而不必为页面上的每个控件都重复提及。
我查看了我们已有的一个页面,它看起来很混乱,如果你问我的话。
我在这里错过了什么吗?
或者这种方法已经过时了,有更好的方法吗? 欢迎所有输入 (+/-)。
谢谢!
I was just given a project that needs to be localized.
I just ran into meta:resourcekey and how it's used in conjunction with local resource files.
My question is: do I have to do it this way?
Consider this example right off MSDN:
<asp:Button ID="Button1" runat="server" Text="DefaultText"
meta:resourcekey="Button1" />
If I'm reading this for the first time (which I am), I'd say "why specify Button1
twice?"
If <@ Page @>
already has Culture
set to auto
, and there are local resource files, go and find each control's local resources, if any, without having to do this double-mention for EVERY single control on the page.
I looked at a page we already have that does that and it just looks like clutter, if you ask me.
Am I missing something here?
Or is this method obsolete and there is a better way to do it?
All input (+/-) is appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我同意在
meta:resourcekey
属性中再次指定控件标识符似乎是多余的,但它的存在是有充分理由的。假设您正在维护一个以 42 种语言本地化的应用程序。假设其中一些语言的翻译外包给 6 个不同的承包商。
现在假设您必须将按钮的
ID
从Button1
更改为defaultButton
。最好的方法是什么?更改
ID
属性,保留meta:resourcekey
不变,然后继续快乐,或者更改
ID
属性,然后修改数十个资源文件,以便它们使用新的ID
,然后打电话给所有承包商,要求他们修改他们为您提供的资源文件?I agree that specifying the control identifier a second time in the
meta:resourcekey
attribute seems redundant, but it's there for a good reason.Suppose you're maintaining an application localized in, say, 42 languages. Suppose translations for some of those languages are outsourced to, say, 6 different contractors.
Now imagine you absolutely have to change the
ID
of your button fromButton1
todefaultButton
. What would be the best way to do that?Change the
ID
attribute, leavemeta:resourcekey
as it is, and be on your merry way, orChange the
ID
attribute, then modify dozens of resource files so they use the newID
, then give a call to all your contractors asking them to modify the resource files they provide you?