本地化 WebForms,但不过度使用 meta:resourcekey

发布于 2024-10-01 10:22:03 字数 536 浏览 8 评论 0原文

我刚刚收到一个需要本地化的项目。
我刚刚遇到了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女七分熟 2024-10-08 10:22:03

我同意在 meta:resourcekey 属性中再次指定控件标识符似乎是多余的,但它的存在是有充分理由的。

假设您正在维护一个以 42 种语言本地化的应用程序。假设其中一些语言的翻译外包给 6 个不同的承包商。

现在假设您必须将按钮的 IDButton1 更改为 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 from Button1 to defaultButton. What would be the best way to do that?

  • Change the ID attribute, leave meta:resourcekey as it is, and be on your merry way, or

  • Change the ID attribute, then modify dozens of resource files so they use the new ID, then give a call to all your contractors asking them to modify the resource files they provide you?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文