Multi-Lang website using database

Last post 12-01-2004 2:57 PM by AndsX. 2 replies.

Sort Posts:

  • Multi-Lang website using database

    11-30-2004, 9:35 PM
    • Member
      720 point Member
    • AndsX
    • Member since 07-12-2004, 9:11 AM
    • Posts 155
    We have to convert a website to support mulitple languages. The bottlneck here is that the lanaguage translation data will be retrieved from the database.

    All the data to be translated is avaliable as a server control so I am thinking of the quickest and cleanest possbile method to achieve this.

    Since all my pages inehirt from a BasePage i was thinking of writing something like this in the preRender method of the base page

    For each obj in PageControl
    obj.text=TranslateText(obj.text,lanaguageid)
    end each

    But is text property common to all server controls i guess not..

    Can ony one think of simpler way to achieve this.


  • Re: Multi-Lang website using database

    12-01-2004, 9:27 AM
    • Member
      110 point Member
    • stebe
    • Member since 07-14-2004, 11:09 AM
    • Posts 22
    I don't know of the pros and cons, but here is how I did it.
    I created a class called langHashTable.vb and this code:

    Imports System.Data.OleDb
    Imports FCNetlearning.Global

    Public Class langHashTable

    Public Shared hashSwe As New Hashtable
    Public Shared hashEng As New Hashtable

    Public Shared Sub FillHashTable()
    hashSwe.Clear()
    hashEng.Clear()
    myConnection.Close()
    Dim myCommand As New OleDbCommand("Select * From LangTbl", myConnection)
    Dim dr As OleDbDataReader
    myConnection.Open()
    dr = myCommand.ExecuteReader
    Dim Swe, Eng As String
    While dr.Read()

    hashSwe.Add(dr.GetString(0), dr.GetString(1))
    hashEng.Add(dr.GetString(0), dr.GetString(2))

    End While
    myConnection.Close()
    End Sub
    End Class

    I have one Hashtable for each language. In the databasetable I have one key-column and one column for each language. I change language for every component like this:

    lbUInst.Text = hashSwe.Item("lbUInst")

    where lbUInst is the label and "lbUInst" is the key.
  • Re: Multi-Lang website using database

    12-01-2004, 2:40 PM
    • Member
      720 point Member
    • AndsX
    • Member since 07-12-2004, 9:11 AM
    • Posts 155

    have one Hashtable for each language. In the databasetable I have one key-column and one column for each language. I change language for every component like this:

    lbUInst.Text = hashSwe.Item("lbUInst")


    I want to avoid doing this. I want to put the translation in one common place like the base page or some http modules...

    I am thinking of way to get a property which is common to all the server controls...

    Has anyone done something like this?
Page 1 of 1 (3 items)