Multiple languages ​​(English, Dutch, Finnish, French, Hungarian, Bangla, Italian) in ASP.NET with SQL Server!

I am developing a web application in ASP.NET 3.5 with SQL Server 2008. I need several languages ​​like English, Dutch, Finnish, etc. I can do this using System.Resources and System.Globalization. but I can’t convert the language whose data comes from the database. How can I solve this ???

0
source share
2 answers

I would recommend using two tables for a table in which you 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 

This method can be used:

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

( , lang ProductLoc)

: ,

+3

, , , LanguageId .

CREATE TABLE Languages (
    LanguageId int IDENTITY(1, 1) PRIMARY KEY
    LanguageCode nvarchar(5)
    LanguageName nvarchar(25)
)
GO

INSERT INTO Languages (LanguageCode, LanguageName)
    VALUES (N'en-CA', N'English Canada')
GO
INSERT INTO Languages (LanguageCode, LanguageName)
    VALUES (N'fr-CA', N'French Canada')
GO
INSERT INTO Languages (LanguageCode, LanguageName)
    VALUES (N'de-GE', N'German Germany')
GO

CREATE TABLE LabelTexts (
    LabelTextId int IDENTITY(1, 1) PRIMARY KEY
    FormName nvarchar(50) NOT NULL
    LabelName nvarchar(50) NOT NULL
    LanguageId int NOT NULL
    LabelText nvarchar(2000) NOT NULL
)
GO
ALTER TABLE LabelTexts
ADD CONSTRAINT FK_Language FOREIGN KEY REFERENCING Languages(LanguageId)
GO

INSERT INTO LabelTexts (FormName, LabelName, LanguageId, LabelText)
    VALUES (N'frmMain', N'label1', 1, N'Enter the information for customer here:')
GO
INSERT INTO LabelTexts (FormName, LabelName, LanguageId, LabelText)
    VALUES (N'frmMain', N'label1', 2, N'Saisir les informations du client ici :')
GO
-- etc.

, , , , , , ! !

, , :

select LabelText
    from LabelTexts
    where LanguageId = 1
        and FormName LIKE N'frmMain'
        and LabelName LIKE N'label1'

:

select dbo.GetLabelText(N'frmMain', N'label1', 1)

, SELECT. .

+1

Source: https://habr.com/ru/post/1743239/


All Articles