|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Dynamical content display
Hi guys!
I hope someone will help me to find the optimal solution for this. I have some system that is written in asp. The problem is that I need exactly the same system in 5 different languages. I need to display the content in different language. I'm wondering how to do this right. Create Data Base ? Create one big asp file ? If I'm creating a DB where each field is a word/sentence in different language ,it will be a table with 50 or more fileds. If I create an asp file I will need to create an array and put words/sentences in each element.I have many files that I nedd to translate this way. If someone has any idea it will be very helpful. |
|
#2
|
||||
|
||||
|
my pages are in 4 languages (usually). what i use is conditional includes which works rather complicated in ASP. I try to explain.
Put this at the top of your page (without <% %>): Code:
<SCRIPT Language=VBScript RUNAT=SERVER>
Function getMappedFileAsString(byVal strFilename)
Const ForReading = 1
Dim fso
Set fso = Server.CreateObject("Scripting.FilesystemObject")
Dim ts
Set ts = fso.OpenTextFile(Server.MapPath(strFilename), ForReading)
getMappedFileAsString = ts.ReadAll
ts.close
Set ts = nothing
Set fso = Nothing
End Function
</SCRIPT>
Then the conditional include of language files: Code:
'map to the existing language files
languagefile_en = Server.MapPath("inc_language_en.asp")
languagefile_ne = Server.MapPath("inc_language_ne.asp")
languagefile_de = Server.MapPath("inc_language_de.asp")
languagefile_fr = Server.MapPath("inc_language_fr.asp")
'include appropriate language file (selection between english, dutch, german, french)
'when no user is logged in (login.asp) then include the english library by default
'when no language is defined, then get the english include file
Dim strInclude
If str_users_language = "" Then
strInclude = getMappedFileAsString("inc_language_en.asp")
ElseIf str_users_language = "en" Then
strInclude = getMappedFileAsString("inc_language_en.asp")
ElseIf str_users_language = "ne" Then
strInclude = getMappedFileAsString("inc_language_ne.asp")
ElseIf str_users_language = "de" Then
strInclude = getMappedFileAsString("inc_language_de.asp")
ElseIf str_users_language = "fr" Then
strInclude = getMappedFileAsString("inc_language_fr.asp")
End If
Execute strInclude
now you generate different include language files called (in your case 5) - inc_language_en.asp - inc_language_ne.asp - inc_language_de.asp - inc_language_fr.asp which look like (no <% %>) tags!: Code:
Function getFileName()
Dim lsPath, arPath
' Obtain the virtual file path
lsPath = Request.ServerVariables("SCRIPT_NAME")
' Split the path along the /s. This creates an
' one-dimensional array
arPath = Split(lsPath, "/")
' The last item in the array contains the file name
GetFileName =arPath(UBound(arPath,1))
End Function
'shared files
'------------------------------------------------------------------------------
If GetFileName = "index.asp" Then
interhrm = "InterHRM"
welcome = "Welcome to InterHRM"
intro = "electronic Human Resource Management (eHRM) systems"
service = "We offer you the opportunity to comply with competence- and performancemanagement by means of eHRM (the usage of internettechnology to support HRM purposes)." & "<br>" & "Practise points out that organisations which introduce eHRM solutions, get provable benefit on a diversity of fields, such as:"
item_1 = "lower company costs for the execution of HRM-processes, for example by decreasing the administrative HRM-tasks which come along with eHRM, shorter pass through times"
item_2 = "larger involvement and higher employee satisfaction: Because eHRM is a way to assign more responsibilities to the employees and managers themselves, with respect to HRM"
End If
for all 5 languages.... good luck |
|
#3
|
|||
|
|||
|
Thank you for your answer. Good work!
I don't understand a few things .I don't understand why not to use <%%> tags and what are you doing in the include files? Do you write a translation for each sentence? Thank you again. |
|
#4
|
||||
|
||||
|
Quote:
The reason not to use <% %> is because the first code part is written in VB and is executing the include files. VB doesn't need these tags so thats the reason. In the include files (in your case you will have 5 separate include files for each language) you define for each sentence the translation as a string. When calling a variable in your code, then the string will be displayed. The advantage of this method is its very fast in loading. here is some more info: http://www.4guysfromrolla.com/webtech/022504-1.shtml |
![]() |
| Viewing: ASP Free Forums > Other > Programming Help > Dynamical content display |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|