Multilangual website using ASP and a database

Posted by Noam Smadja on Stack Overflow See other posts from Stack Overflow or by Noam Smadja
Published on 2010-06-15T17:29:42Z Indexed on 2010/06/15 17:32 UTC
Read the original article Hit count: 164

i want to consult about something i do.

my website has 3 languages. Hebrew (main), english and russian. i am using a database having a table with the fields: ID, fieldName, 1, 2, 3. where 1 2 3 are the languages.

upon entering the website language 1 (hebrew) is chosen automaticly until you choose another. and saved as a session("currentLanguage").

i wrote a function langstirng whice recieves a field name and prints the value acording to the language in session("currentLanguage"):

Dim languageStrings
Set languageStrings = Server.CreateObject("ADODB.Recordset")
languageStrings.ActiveConnection = MM_KerenDB_STRING
languageStrings.Source = "SELECT fieldName,"&current_Language&"FROM Multilangual"
languageStrings.CursorType = 0
languageStrings.CursorLocation = 2
languageStrings.LockType = 1
languageStrings.Open()

sub langstring(fieldName)
    do while NOT(languageStrings.EOF)
        if (languageStrings.fields.item("fieldName").value = fieldName) then
            exit do
        else
            languageStrings.movenext
        end if
    loop

if (languageStrings.EOF) then
    response.Write("***"&fieldName&"***")
else
    response.Write(languageStrings.fields.item(currentLanguage+1).value)
end if
    languageStrings.movefirst
end sub

and i use it like so: <div>langstring("header")</div>.

i find it stupid that i keep sending the query to the server on any and every page. since the multilangual table does not change "THAT" often i want to somehow save the recordset for the current browsing.

I am looking help for THIS solution, Please.

© Stack Overflow or respective owner

Related posts about database

Related posts about asp-classic