Localized Web Apps
First is to duplicate code. We create a web page for English and for German: WebPageGerman and WebPageEnglish. In the session CreatePage event, we get have pagename being empty for the default page and there we can decide which page should show. For that we look into the session headers and if the accepted language includes German (de), we show the German page. Else the english page:
Function CreatePage(PageName As String) As WebPageThe second and maybe better way is to change the language in the WebPage open event and switch the labels to show the right texts:
if PageName = "" then // start page
dim Lang as string = Session.Header("Accept-Language")
if instr(lang, "de")>0 then
Return WebPageGerman
else
Return WebPageEnglish
end if
end if
End Function
Sub Open()This way you avoid duplicate code.
dim Lang as string = Session.Header("Accept-Language")
if instr(lang, "de")>0 then
label1.text = "Hallo Leute"
end if
End Sub
Example projects: multilanguageexamples.zip