Using SQL for localization instead of RESX files in ASP.NET

﹥>﹥吖頭↗ 提交于 2019-12-21 12:55:34

问题


I'm thinking of developing the following but wondering if it already exists out there:

I need a SQL based solution for assigning and managing localization text values for an asp.net site instead of using RESX files. This helps maintain text on the site without having to take it down for deployment whenever an update is required.

Thanks.


回答1:


We actually went down that path, and ended up with a really really slow web site - ripping out the SQL-based translation mechanism and using the ASP.NET resources gave us a significant performance boost. So I can't really recommend you do that same thing.... (and yes - we were caching and optimizing for throughput and everything - and the SQL based stuff was still significantly slower).

You get what you pay for - the SQL based approach was more flexible in terms of being able to "translate" on the fly, and fix typos and stuff. But in the end, in our app (Webforms, .NET 2.0 at that time), using resources proved to be the only viable way to go.




回答2:


We did this (SQL-Based Translation) and we are really happy with the result! We developed an interface for translation-agencies to perform the updates to the page online. As a side effect, the solution started to serve as content-management system. If you cache your data, performance is not an issue. The downside is, that we invested multiple hundreds of hours into our solution. (I would guess sth. arround 600 hours, but I could check.).




回答3:


We ended up with a hybrid solution where users could edit content into a database but the application then created a .resx which was deployed manually.

You could also bypass the server translation altogether and do translation in jQuery on the client which is an approach I have used successfully.




回答4:


I'm not sure about the website restart, but at least using .NET MVC is very convenient and I haven't noticed that restart problem, and, if occurs, how often you need to update the resx files? For bigger projects I use to create a solution with multiple projects, one for the localization, something like this:

  • MyApp.Localization
    • Model
    • Page
    • File1.resx
  • MyApp.Core
  • MyApp.Web

Then in the Web project I add a reference to the Localization project, and use it like

@MyApp.Localization.Model.Customer.CustomerName

@MyApp.Localization.Page.About.PageTitle

@MyApp.Localization.File1.Paragraph1

Everytime I change the translated text, I either upload an updated .dll or copy the .resx files.

NOTE: You need to set your resx files to PUBLIC, so can be accessed as strongly typed.




回答5:


I created a SQL based translation scheme. But I only load the needed translations for a given page when it is requested, and just the ones for that particular page.

Those get loaded into a dictionary object when the page reloads and cached during the session. Then is just does text replacement based off a lookup on that.

Pretty much all of it is dynamically generated, and includes user defined content that must be translated, so the flexibility is key.

Performance is quite fast, the SQL queries to retrieve all the data take much longer (relatively speaking).



来源:https://stackoverflow.com/questions/2617856/using-sql-for-localization-instead-of-resx-files-in-asp-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!