問題描述
我一直在使用 .NET 內置的本地化功能,它們似乎都依賴于將數據放入 resx 文件中.
I've been playing with the .NET built in localization features and they seem to all rely on putting data in resx files.
但大多數系統不能依賴此,因為它們是數據庫驅動的.那么你如何解決這個問題呢?是否有內置的 .NET 方式,或者您是否在 SQL 中創建翻譯表并手動完成所有操作?如果您必須在大多數網站上執行此操作,是否有任何理由甚至使用 resx 本地化方式?
But most systems can't rely on this because they are database driven. So how do you solve this issue? Is there a built in .NET way, or do you create a translations table in SQL and do it all manually? And if you have to do this on the majority of your sites, is there any reason to even use the resx way of localization?
這方面的一個例子是我的網站上有一個常見問題解答列表,我將此列表保存在數據庫中,以便我可以輕松添加/刪除更多內容,但是將其放入數據庫中,我無法翻譯此信息翻譯成多種語言.
An example of this is I have an FAQ list on my site, I keep this list in the database so I can easily add/remove more, but by putting it in the database, I have no good way have translating this information into multiple languages.
推薦答案
在我看來,本地化動態內容(例如,您的常見問題解答)應該由您在數據庫中完成.根據您的問題的存儲方式,我可能會創建一個區域設置"列并在從數據庫中選擇常見問題解答問題時使用它.我不確定當您開始本地化大量表時這是否會很好地擴展.
In my opinion, localizing dynamic content (e.g., your FAQ) should be done by you in your database. Depending on how your questions are stored, I would probably create a "locale" column and use that when selecting the FAQ questions from the database. I'm not sure if this would scale very well when you started localizing lots of tables.
對于靜態內容(例如,表單字段標簽、靜態文本、圖標等),您應該可以使用基于文件的資源.但是,如果您真的想這樣做,看起來創建一個可以處理此問題的自定義資源提供程序實現并不難.
For static content (e.g, form field labels, static text, icons, etc) you should probably be just fine using file-based resources. If you really wanted to, however, it looks like it wouldn't be super hard to create a custom resource provider implementation that could handle this.
以下是一些相關鏈接:
- http://channel9.msdn.com/forums/Coffeehouse/250892-Localizing-with-a-database-or-resx-files/
- http://weblogs.asp.net/scottgu/archive/2006/05/30/ASP.NET-2.0-Localization-_2800_Video_2C00_-Whitepaper_2C00_-and-Database-Provider-Support_2900_.aspx
- http://www.arcencus.nl/Blogs/tabid/105/EntryID/20/Default.aspx
- http://msdn.microsoft.com/en-us/library/aa905797.aspx
- http://www.codeproject.com/KB/aspnet/customsqlserverprovider.aspx
這篇關于如何本地化數據庫驅動的網站的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!