在 .net 站点中使用资源文件的最佳替代方案
过去我使用 asp.net 内置的资源文件来处理本地化。它运行得很好,我们发现它在我们的业务中易于使用和维护。
但有一个很大的缺点 - 我们客户的支持团队无法自行更新资源文件。我们有一个大型项目即将启动,允许外部支持团队管理本地化的选项是一个主要要求。到目前为止,我们的客户只需联系我们,我们就会翻译该作品,然后将更新的 resx 文件滚动到实时服务器。
我知道更新 resx 文件会导致应用程序重新编译,并且我不喜欢允许非技术人员下载并弄乱 resx 文件的想法(更不用说在实时环境中未编译该网站),所以我想知道除了走数据库路线之外,我们还有其他选择吗?
如果我们确实必须将这种类型的本地化功能构建到几个数据库表中,是否有人有任何好的开始模板?
不确定这是否有助于了解,但我们正在讨论的网站将被本地化为大约 15 种不同的语言,包括中文和阿拉伯语。翻译将应用于 aspx 页面和 XML 中,从而将我们的系统留给第三方。
In the past I have used asp.net's built in Resource files for handling localization. It's worked pretty well and we find it easy to use and maintain in our business.
There is one big drawback though - our client's support teams can't update the resource files themselves. We have a big project starting soon and the option to allow the external support team manage localization is a main requirement. Up until now we have had clients just contact us, we get the piece translated and then roll the updated resx file to the live server.
I know that updating a resx file causes the application to recompile and I don't like the idea of allowing non techies download and mess around with a resx file (not to mention having the site uncompiled in a live environment) so I'm wondering if there are any other options available to us other than going down the database route?
If we do have to build this type of localization functionality into a few database tables, does anyone have any good templates for starting off?
Not sure if it helps knowing or not but the site we're talking about building here would be localized into about 15 different languages including chineese and arabic. The translations would be applied onto the aspx pages and in the XML that would leave our system to third parties.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
无论您做什么,您可能都需要编写自定义ResourceProvider。
您可能会考虑使用 XML 作为可本地化资源的源 - 在这种情况下您可以使用未编译的 resx 文件,但我想这就是您所抱怨的。否则,您可以使用捆绑文件,类似于Java属性,我的意思是带有键=值对的纯文本文件。这应该很容易编辑。
Whatever you do, you will probably need to write custom ResourceProvider.
You may think of using XML as a source for your localizable resources - in that case you can use uncompiled resx files, but I guess that is what you are complaining about. Otherwise, you can use bundle files, similar to Java properties, I mean plain text file with key=value pairs. That should be very easy to edit.
当然 - 使用配置文件。这基本上是一个 XML 文件。
您可以为每种语言创建一个文件,也可以将它们合并到一个文件中。
Sure - use a config file. This is basically an XML file.
You can have one file for each language, or combine them in one file.
不管你信不信,你不是第一个有这个想法的人! :) 这是我几年前发现的一篇关于如何实现自定义资源的文章 .NET 的提供商。您可以在代码中保留旧的基于资源的方法,并让提供商从您喜欢的任何地方获取数据。
Believe it or not, you're not the first one with the idea! :) Here's an article I found a few years ago on how to implement a custom resource provider for .NET. You can keep your old resource-based approach in your code, and have the provider take the data from wherever you like.
与其编写自己的资源提供程序,也许像 ResX Online Translator 这样的在线翻译器会有所帮助?翻译人员无需下载任何 resx,文件会自动上传到您的实时(或开发)asp.net 应用程序。
Instead of writing your own resource provider maybe an online translator like ResX Online Translator would help? The translators don't have to download any resx, and the files are automatically uploaded to your live (or dev) asp.net application.
使用 Microsoft MAT 或编写您自己的 MAT 提供程序。有关其网站的更多信息:https://developer.microsoft。 com/en-us/windows/develop/multilingual-app-toolkit;-)
Use Microsoft MAT or write your own provider for MAT. More info on their website: https://developer.microsoft.com/en-us/windows/develop/multilingual-app-toolkit ;-)