ASP.Net / MySQL : Translating content into several languages

后端 未结 2 1901
执念已碎
执念已碎 2021-01-06 11:49

I have an ASP.Net website which uses a MySQL database for the back end. The website is an English e-commerce system, and we are looking at the possibility of translating it

2条回答
  •  情深已故
    2021-01-06 12:28

    In your case, I would recommend using two tables:

    Product
    -------------------------------
    ProductID  |  Price   |  Stock 
    -------------------------------
    10         |   10     |   15
    
    
    ProductLoc
    -----------------------------------------------
    ProductID  | Lang   | Name      |  Description
    -----------------------------------------------
     10        |  EN    | Bike      |  Excellent Bike 
     10        |  ES    | Bicicleta |  Excelente bici 
    

    This way you can use:

    SELECT * FROM 
    Product LEFT JOIN ProductLoc ON Product.ProductID = ProductLoc.ProductID 
                                   AND ProductLoc.Lang = @CurrentLang
    

    (Left join just in case there is no record for the current lang in the ProductLoc table)

提交回复
热议问题