N
.nLL
got a multi languagel site.
my aproach was to create
CREATE TABLE [dbo].[languages](
[lang] [nvarchar](3) NOT NULL,
[lang1] [nvarchar](200) NULL,
[lang2] [nvarchar](200) NULL,
[lang3] [nvarchar](200) NULL,
[lang4] [nvarchar](200) NULL,
........................
<SNIP>
........................
[lang310] [nvarchar](200) NULL
) ON [PRIMARY]
have first row language identifier ( [lang] [nvarchar](3) NOT NULL,) and
rest as language source so lang2 to lang310 would have translations
if i want to add another lang i would just add another row with that
language
and my calssic asp function is
getLang("lang1","en")
-----------------------------------------------------------------------------------------------
Function getLang(myInput,myLang)
Set MyCacheForLanguages = New DataCache
MyCacheForLanguages.ConnectionString = SqlConn
LanguagesSQL = "SELECT * FROM languages where lang='"&myLang&"'"
Set CacheRsForLanguages = MyCacheForLanguages.GetRecordset(LanguagesSQL)
Do While not CacheRsForLanguages.EOF
For i = 0 To CacheRsForLanguages.Fields.Count - 1
If CacheRsForLanguages.Fields.Item(i).name=myInput Then
getLang = CacheRsForLanguages.Fields.Item(i).value
Exit for
End if
Next
CacheRsForLanguages.MoveNext
Loop
Set CacheRsForLanguages = Nothing
Set MyCacheForLanguages = Nothing
End function
note New DataCache , it is memory caching class i use
----------------------------------------------------------------------------------------------
this combination works fine when i have couple of coulmns in language table
but i have over 300 columns and looping slowes server down.
i need another approach to make this combination faster. may be in function
or in select statement.
can anyone think of something faster without changing table stracture
my aproach was to create
CREATE TABLE [dbo].[languages](
[lang] [nvarchar](3) NOT NULL,
[lang1] [nvarchar](200) NULL,
[lang2] [nvarchar](200) NULL,
[lang3] [nvarchar](200) NULL,
[lang4] [nvarchar](200) NULL,
........................
<SNIP>
........................
[lang310] [nvarchar](200) NULL
) ON [PRIMARY]
have first row language identifier ( [lang] [nvarchar](3) NOT NULL,) and
rest as language source so lang2 to lang310 would have translations
if i want to add another lang i would just add another row with that
language
and my calssic asp function is
getLang("lang1","en")
-----------------------------------------------------------------------------------------------
Function getLang(myInput,myLang)
Set MyCacheForLanguages = New DataCache
MyCacheForLanguages.ConnectionString = SqlConn
LanguagesSQL = "SELECT * FROM languages where lang='"&myLang&"'"
Set CacheRsForLanguages = MyCacheForLanguages.GetRecordset(LanguagesSQL)
Do While not CacheRsForLanguages.EOF
For i = 0 To CacheRsForLanguages.Fields.Count - 1
If CacheRsForLanguages.Fields.Item(i).name=myInput Then
getLang = CacheRsForLanguages.Fields.Item(i).value
Exit for
End if
Next
CacheRsForLanguages.MoveNext
Loop
Set CacheRsForLanguages = Nothing
Set MyCacheForLanguages = Nothing
End function
note New DataCache , it is memory caching class i use
----------------------------------------------------------------------------------------------
this combination works fine when i have couple of coulmns in language table
but i have over 300 columns and looping slowes server down.
i need another approach to make this combination faster. may be in function
or in select statement.
can anyone think of something faster without changing table stracture