开发者

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

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 as开发者_运维百科p.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.


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.


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.).


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.


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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜