问题描述
我正在使用SQL Server 2008在ASP.NET 3.5中开发一个Web应用程序.我需要多种语言,例如英语,荷兰语,芬兰语等.我可以通过使用System.Resources和System.Globalization来实现.但是我无法转换来自数据库的数据的语言.我该如何解决呢?
I am developing a web Application in ASP.NET 3.5 with SQL Server 2008. I need Multiple Language such as English, Dutch, Finnish etc. I can do it by using System.Resources and System.Globalization. but I can't convert the Language which data come from database.How can I solve it ???
推荐答案
我建议对需要本地化的表使用两个表.
示例:
I would recommend using two tables for the table that your need localization.
Example:
Product
-------------------------------
ProductID | Price | Stock
-------------------------------
10 | 10 | 15
ProductLoc
-----------------------------------------------
ProductID | Lang | Name | Description
-----------------------------------------------
10 | EN | Bike | Excellent Bike
10 | ES | Bicicleta | Excelente bici
这种方式可以使用:
SELECT * FROM
Product LEFT JOIN ProductLoc ON Product.ProductID = ProductLoc.ProductID
AND ProductLoc.Lang = @CurrentLang
(如果在ProductLoc表中没有当前lang的记录,则进行左联接)
(Left join just in case there is no record for the current lang in the ProductLoc table)
免责声明:文本摘自我的另一个答案
这篇关于带有SQL Server的ASP.NET中的多种语言(英语,荷兰语,芬兰语,法语,匈牙利语,孟加拉语,意大利语)!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!